• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Help with level save system

A

Amith Haripersad

Guest
Hey Guys

I managed to download a very old yet simple tutorial of making a level lock/unlock system.
The problem is, how do i add a save system to it?
A game will start will level 01 unlocked. Once this level is completed, level 02 gets unlocked. How do i save this progress so that when the player restarts the game, it does not lock all levels that the player completed already?
If anyone could please have a look at the example and modify or assist with a solution, i would be really greatful
This is the code...

Code:
CREATE EVENT
if (score>50)
{
    sprite_index=sprite_level_02;
    image_index=1;
    image_speed=0;
}
else
sprite_index=sprite_level_02;
image_index=0;
image_speed=0;
{
}

MOUSE LEFT PRESSED EVENT
if (score>50)
{
    transition_kind=0;
    room_goto(level_02);
}
else
{
    show_message("get 50 points to unlock this level");
}
 

O.Stogden

Member
Best to use an ini for this kind of thing really.

When your score first passes 50, put something like this in:

Code:
ini_open("progress.ini")
ini_write_real('progress', 'level2', true)
ini_close()
Then when you wish to check, probably upon opening your level select.

Code:
ini_open("progress.ini")
level2unlocked=ini_read_real('progress', 'level2', false)
ini_close()
Then do a check to see if level2unlocked is equal to true or false.
 
A

Amith Haripersad

Guest
Best to use an ini for this kind of thing really.

When your score first passes 50, put something like this in:

Code:
ini_open("progress.ini")
ini_write_real('progress', 'level2', true)
ini_close()
Then when you wish to check, probably upon opening your level select.

Code:
ini_open("progress.ini")
level2unlocked=ini_read_real('progress', 'level2', false)
ini_close()
Then do a check to see if level2unlocked is equal to true or false.
Thank you but i cant seem to get it to work
Would you mind updating my code in order for me to see where i am going wrong please? would appreciate that
 

O.Stogden

Member
I would need to see what you're trying in order to help.

Once you achieve score 50, or when you finish level one, put the first piece of my code in, that opens the ini file, and writes a line to it saying that level 2 is unlocked.

Then, perhaps in a create event of a controller object in the level select room, have it run the second piece of code I put up, that reads from the ini file and sets "global.level2unlocked" to either false or true, depending on whether the level is unlocked or not. I've changed to a global variable here incase each level in the level select has a separate object you click on for starting the level

Then you can make a check in the object that you click on to start level 2:

Code:
if global.level2unlocked=true
{
playable=true
}
else
{
playable=false
}
I can't get more specific than this without seeing your code.
 
Top