FIFE forums

Please login or register.

Login with username, password and session length
Advanced search  

News:

FIFE 0.4.0 has been released on 15th of January, 2017!

Author Topic: A question about real-time map editing  (Read 2019 times)

Cerberus108

  • Newbie
  • Posts: 1
    • View Profile
A question about real-time map editing
« on: October 30, 2011, 04:24:21 am »

Hi there, it's been a while since I've first read about FIFE, and just a few days ago I finally decided to start developing my project. My goal is to create a clone of Pharaoh, a 1999 game by Impression Games and Sierra: basically, it's a city-builder similar to Zeus, Caesar etc.

The first major obstacle I came up with is the following: in my game, I have the need to let the player edit the map in real-time, for example by letting him assign a specific value to a cell (for instance, with the purpose to mark it as an obstacle). I've looked for a hint in Unknown Horizons source files, but it seems that when it comes to building, that game just adds or removes instances on the map, which is not exactly what I'm looking for.

How can I render my need in FIFE? How can I edit a value on the map, for instance the terrain type of a cell (I mean the tag "o" in the map XML), and then refresh the map on screen? There are no tutorials/examples that could make me realize it, and since I'm not pretty skilled neither with Python nor with FIFE, I have no clue about how to solve this problem by myself.

Thanks in advance,  :) and sorry for my not-that-good English.  :-\
Logged

vtchill

  • Developer
  • Full Member
  • *
  • Posts: 206
    • View Profile
Re: A question about real-time map editing
« Reply #1 on: October 31, 2011, 07:52:51 am »

Hello and welcome to the FIFE community.

It sounds to me like you basically want the functionality that the FIFE map editor does, but in a little more interactive game form geared towards players. You can take a look at the editor code in the <fife>/tools/editor directory to get some hints.

I will provide a quick overview to hopefully help you along
First do not think of the map file (the actual .xml file on disk) as always needing to be edited and reloaded. Once the base map file is loaded by FIFE everything else such as modification to cells and adding/removing instances is done in memory. Since these are real-time edits they will be displayed on the currently loaded map which can then be saved to disk sometime in the future. There should not be a need to reload the map every time a change is made. Instead you could either save the map at known intervals or allow the user to specify when to save it. Once the map file is loaded by FIFE you should be able to access all the data that it contained through functions exposed by the FIFE engine which should give you the functionality you are looking for to do real-time editing of the currently loaded map.

Good luck and feel free to post back or visit us on our IRC channel #fife @ freenode
Logged