Page 1 of 1

Newbie Asks: How to Save in Multiple level game

PostPosted: Mon Apr 16, 2012 9:35 pm
by ggesterGamePro99
I'm a newbie but i have some game programming experience from before and i've played games, and i know about games and stuff(not much but so so)
ANyways, basically

I'm making a multilevel game. How do i save it so that the user can start where he left off, at the level where he left off.

I could go as far as to also say..what if i have a game where the user collects a bunch of stuff and has earned money or something and i want him to when he comes back to his game days or hours later to start the game and start off with all the items and money he had last time. So how do you save that too.

I'm guessing you would write some kind of text file teeling which level you save at..and to also write all your score and items and money into that text file. Right?

But how would i do it?

Re: Newbie Asks: How to Save in Multiple level game

PostPosted: Mon Apr 16, 2012 11:35 pm
by skydereign
To save you can either use gE's saveVars/loadVars functions, or use FILE* operations. I'd suggest using saveVars and loadVars since you are just starting out. Essentially you create variables and put them into a save group. If you wanted to save score, you would create a score variable, and put that into a savegroup, for instance "player_save". You can add other things to the save group, such as a variable that holds the player's life, and perhaps an array to hold items obtained. Then to save, put this code into whatever event saves your game.
Code: Select all
saveVars("save_file", "player_save");

Then when you start the game (want to load the save), you do the reverse operation.
Code: Select all
loadVars("save_file", "player_save");