Advertisement

non-static portions of maps

Started by January 31, 2000 05:45 PM
2 comments, last by Thathmew 24 years, 10 months ago
How area people dealing with non-static portions of a map? Things like doors, items, or characters? This is of key importance for savegames, because one doesn''t want to save all the static data, so it needs to be seperate from the non-static. Which is relatively easy, but what if I''m creating a world which almost all tiles/areas are potentially non-static, i.e. all walls might be destroyed by a strong enough blow? Does anyone have a good solution to this that doesn''t involve saving the whole world? Or just saving the changed parts(which in endgames becomes potentially ''nigh the whole world)? thanks, -mat
mat williamsLead Programmer, DesignerZero Sum Softwarewww.zero-sum.com
I really think this depends on what your game is like. For a game that has random encounters and almost all static elements, just saving the character is enough. Certain states like if certain objects have been destroyed, or doors have been opened, can, in actuallity, be attached to the player data as a collection of flags.

On the otherhand, if you have a game where the map is created dynamically, and is different each game, you''re going to have to save the entire map. Simulation games, or age of empire games are like this. Don''t be suprised if a saved game takes up a couple of megs of data.

In terms of seperating the data, saved from unsaved, this comes into play during your game design. I would suggest making your map element structure have all the "to save" data in a set of layers, and your "static" data in others. That way you can just iterate through your map, saving out the data you need.

Another approach might be to keep a list of pointers to each of the elements that should be saved, so you can just go through that list when saving. I''m not sure if this would work or be terribly efficient.

Don''t forget that speed really shouldn''t be thought of too much when writing the save/load functions. If you have to go through the map one element after another while comparing it to the disk-based "original world", I think that would be ok.

Advertisement
If you game uses a static world, you could create a giant bitmask that stores which tiles (all objects in Z plane) have been destroyed. If you world is random, most people will store the seed and regenerate the data. For any scene that was partially destroyed you could store a bitmask and if it was completely destroyed, just set a flag.
These bitmasks would be parsed when you loaded each area and compressed back down into masks as you exit the area. With bitmasks you could also pack 8 tiles per byte thereby saving some space.
Here''s what I''d do. I usually have some DWORD or int or something that''s at least a byte stored in the map tile structure. Just set aside one of the bits of this variable to say if the tile is destroyed or not. Then save this whole structure (with the variable inside the structure that contains the bit that tells if it''s destroyed) to the save file! I''m assuming you know how to do this in code, but if you really want a code sample, then e-mail me below. I''d be happy to help you out. Good luck!

ColdfireV
[email=jperegrine@customcall.com]ColdfireV[/email]

This topic is closed to new replies.

Advertisement