M
meme
Guest
Hello everyone, I almost finish my platformer game but I have a doubt on how to do optimize the saving mechanism.
So basically I have a global struct, containing everything, such as lists of player armors, guns, etc, as well as player's coins.
My thought on saving is to get back on our progress which means loading the game is only required once, for me it's inside the "Game Start" event. But does this necessarily means progress just needs to be saved once which is on the "Game End" event of a persistent Game Manager object?
For my game, what needs to be saved is when crafting an item, buy items from a store, equipping items, collect coins from levels, etc.
Most of them are acceptable except for collecting coins since there might be 20 coins collected at once. I know that I can separate the save files but I like it to be organized .
Here's my save script:
Thanks for reading, so what do you think of my theory on loading+saving the game once?
So basically I have a global struct, containing everything, such as lists of player armors, guns, etc, as well as player's coins.
My thought on saving is to get back on our progress which means loading the game is only required once, for me it's inside the "Game Start" event. But does this necessarily means progress just needs to be saved once which is on the "Game End" event of a persistent Game Manager object?
For my game, what needs to be saved is when crafting an item, buy items from a store, equipping items, collect coins from levels, etc.
Most of them are acceptable except for collecting coins since there might be 20 coins collected at once. I know that I can separate the save files but I like it to be organized .
Here's my save script:
GML:
// Save progress
function save_progress()
{
var _struct = {
playerList: global.playerList,
scarfList: global.scarfList,
auraList: global.auraList,
powerList: global.powerList,
levelList: global.levelList,
playerInfo: global.playerInfo
}
// Stuffs
var _string = json_stringify(_struct);
var _buffer = buffer_create(string_byte_length(_string)+1, buffer_fixed, 1);
buffer_write(_buffer, buffer_string, _string);
buffer_save(_buffer, SAVEFILE);
buffer_delete(_buffer);
}