19 Feb 2009

Editor Stage Save and Load

Right now I am still working on the save and load feature of the editor and application. But so far it doesn't look complicated. Each object will save its own data. When loading though, object might need to be created with those data as parameter so it's probably not possible every object loads its own data.

One thing I did significantly different on the editor from the last game is the way the program determine which tile block to put, and it seems to work out much better. The way I am doing now is "dynamically" determine the block to use when each time a tile is added to the stage. The way I have set it up (adding 4 tile at a time), each time a tile is added, the tiles around it and itself has to determine which block to use (2 border, no border, 1 border etc). The important thing is: the recalculation does not traverse beyond the immediate surrounding tiles. Even if it does, it's actually ease to use recursive functions algorithm to go beyond the surrounding tiles, which is much more CPU intensive, but I am 99% certain that is not necessary. To be 100% sure I probably need to do a mathematical proof on this lol...that would be a nice computer science exam question, but hey, I am just trying to make a game here.

The algorithm I used last time is to do the block determination after all the tiles placement has been determined. Doing it this way has 2 disadvantage:

  • The determining functions became long and complex. Very difficult to manage. Although I am not totally sure, but I think the new way will actually cut the complexity down.
  • The user cannot see exactly what they will see in game when they are using the editor. Obviously it can be remanded with a refresh button or just do recalculation of the whole thing when the user add a tile. But both are inferior to the new one, in which the user has immediate feed back with much less recalculation resource.
I actually thought of the new algorithm half way during my development of the old algorithm. But I wasn't too sure if the new one is easy to do and I was already half way through. It seems now the new idea is much better.

No comments: