Windows How can I make save system?

S

SaeedBRI

Guest
I have a badly problem... I made my game but I cant make a save load system on it ... Not a normal one, like a good game... So... If u play a game (like silent age) for your second time, you see the main menu at the first, then if you tap "start" you see... The game saved your progress...
I have 20 levels, and 1 main menu. I want my game to save the levels, but start from main menu...
I mean: for example John is our gamer and he finished four levels, then closed it and next time opened the game and the game started from main menu but when he clicked "continue", the game showed him fourth level.
For your exmples, the names are:
room_main. Room_1. Room_2. ...
Obj_player.
Note:I dont want to save the player's positions.
 
Check the help file for game_save and game_load (or something like that). You can use more complex options to do with ini's and other stuff, but for the basics that will work in the way you wanted.
 
D

DarthTenebris

Guest
You could save the state of the level (completed or not). Upon closing and opening, you could save / load the stats. With that, you can go even further - if the player hasn't completed the level N yet, he cannot play any levels beyond level N.

I personally have this kind of system in my game - but the code is a bit long to share. Also I don't quite plan to share my game's source code. :p
I noticed your *low?* post count - are you simply new to the forum or GML as well? If you have been using it for a while, you should be able to get an theoretical idea on how you can code this.

Hope I helped :)
 

NightFrost

Member
I'm not sure how save_game() and load_game() behave as I've never used them. If they do not fulfill the need, look into filesystem commands ini_open() and ini_close(). Since all you appear to need is to save the furthest level player has reached, all you need to do is open an ini file, write the level number, and close the file. When game starts, the number is read from the file to a variable, and when Continue is picked from menu, the game jumps to that level.
 
B

Brian Le

Guest
You can save that in the ini file like this:
if (file_exists("save.ini")) file_delete("save.ini");
room_name = xyzt;
ini_open("save.ini");
ini_write_string("Save","Room",global.room_name);
ini_close();
and when you press Continue
roomgo = mainmenu
ini_open("save.ini");
roomgo = ini_read_string("Save",Room",global.room_name);
room_goto(roomgo);
plz forgive if I have any error in syntaxes!!!
 
Last edited by a moderator:

RangerX

Member
I'm not sure how save_game() and load_game() behave as I've never used them. If they do not fulfill the need, look into filesystem commands ini_open() and ini_close(). Since all you appear to need is to save the furthest level player has reached, all you need to do is open an ini file, write the level number, and close the file. When game starts, the number is read from the file to a variable, and when Continue is picked from menu, the game jumps to that level.
Just poking on the side "game_save(filename)" is as simple as a game state saved in a file that you decide its name. If the file doesn't exist its automatically created. The game state doesn't save anything dynamic though. (surface, data structures, asset loaded at runtime, etc)
 
Top