So, I'm working on a platform game similar to Jumpman for the C64 but updated to allow non-linear travel and a few RPG-lite elements (heart collection, etc).
Unlike a more typical tile-based game, a key aspect of this game is that each platform can potentially be moved using switches. In addition, there are numerous collectables and objects that move (for example, a bouncing ball).
I deliberated over many save systems, and decided the most fair would be one that recorded an instant savestate every time you entered a new screen. Death is relatively common. When you die, your progress on that screen is reset and you must do the screen over. The savestate is erased when you quit, so to save progress, you must make it to a save station. Both of these need to record the location of numerous actors and then load that data instantly.
Right now my plan is to break the game world into 8 buildings, each with a limited number of screens, so that my save system doesn't have to record 1000's of actors or objects, but I still need a robust system to save and load levels.
My goal is to create a single function that records the current x and y of each platform (each one being a clone), the x and y of each object and various other data.
I have no trouble saving arrays. That much is clear from examples on these boards and the documentation. loadvar and savevar work just fine for my purposes.
The trick for me is automating the autosave feature for platforms, etc.
What I would like is something like a function that is accessed as so: levelFunction (1, "save") where 1 is the level and "save" is the option from three choices (save, load, clear).
When you call the save function, it will check what level I want to save (in this case level '1'), and then save all locations in that level. The code that obviously won't work is:
In Level Script, whenever I like:
levelFunction(1, "save");
In Global Script:
void levelFunction (level, string *levelstate) {
if (strcmp (levelstate, "save") == 0) {
if (level == 1) {
while savedplatform < the total number of platforms {
platformx[savedplatform] = platform.savedplatform.x;
platformy[savedplatform] = platform.savedplatform.y;
savedplatform += 1;
}
while saveditem1 < the total number of item1 {
item1x[saveditem1] = item1.saveditem1.x;
item1y[savedplatform] = item1.saveditem1.y;
saveditem1 += 1;
}
...and so on.
The goal is to be able to save the data of cettain sets of levels at one time, but as you can see, I don't understand enough about the process to get it to work. I've tried a few work-arounds, but can't get it to do what I want it to do.
The next step would be to have a "load" function that would set the x and y of each platform, item1 and so on based on the platformx/y[savedplatform] data, and the item data.
Finally, I should be able to "clear" a level so that I don't have to worry about any events in those levels. It would erase the whole level until the next time I approach it.
The goal is to have levels within buildings to be saved, and then cleared temporarily when you leave the building.
I know that I'm being as clear as mud, but if anyone has any suggestions on how to make this bizarre function work, I'd appreciate it.
Thanks, the community here is awesome!