Game Development Community

Advice on implementing load/save game

by Gianormous Games · in iTorque 2D · 08/27/2011 (3:55 pm) · 2 replies

Hi all -

We're implementing our game in iT2D using game logic in components - loaded and edited via the behavior mechanism from the level file, but all the logic is in C++ code. The components have dynamic state over and above what's saved by the level editor. There's a master game state singleton object that synchronizes everything.

Now I'm looking at serialization. There are two different serialization systems I see in the engine. One is the write() based system, that writes out script files which are then compiled down to dso's (i.e. what's written out by TGB when you save a level file). The other is based on macros in t2dSerialise.h, and writes out a binary format, but architecturally seems to be part of T2D and thus doesn't save out things above T2D in the hierarchy (like components).

My question boils down to understanding the intended use of these two systems, and which is more appropriate for what I'm trying to do.

Thanks!!

#1
09/02/2011 (12:43 pm)
The macro-based serialization is definitely geared to only writing out stock properties of an object. It's main use is for streaming a T2D object from a file. It does not account for dynamic variables.

The write system each object has at the script level takes dynamic properties into consideration and should be able to save. Theoretically, there are multiple approaches to saving out data to a file. You could parse an objects field and save it out to a unique format of your choice, but you will have to write that saver/loader/parser. Overall, this is kind of specific to your game.
#2
09/02/2011 (1:22 pm)
I would use custom serialise and unserialise methods in the object classes. These would just save out relevant information (positions of placeables, repair states, health). Behaviours could make objects actually do their unique stuff, and the behaviours themselves could have serialising methods. The object serialisation would save the behaviour list and call relevant serialisation for each :)