Saving For An Rpg Style Game


The simplest way to go about this would be to put all the data you want to save into one big structure, and write/read that structure to a file.

- Alex
 
Alex. posted on Sep 20 2006 at 02:40 AM said:
The simplest way to go about this would be to put all the data you want to save into one big structure, and write/read that structure to a file.

- Alex
example?
 
Last edited by a moderator:
Err, none off the top of my head, I never used structures in Fenix. I'll look something up for you soon.

- Alex
 
Here you go Goity:

Code:
// Declare structure
struct gameSave;
 int lifepoints;
 int mapX;
 int mapY;
end

// Put data in it
gameSave.lifePoints = 100;
gameSave.mapX = 4;
gameSave.mapY = 7;

// Write it to a file
save("data.sav", gameSave);

// Read it from a file
load("data.sav", gameSave);
Hope this helps, and if all else fails, pay http://fenixonfire.gp32x.de a visit when it re-opens.

- Alex
 
Alex. posted on Sep 20 2006 at 05:58 PM said:
Here you go Goity:

Code:
// Declare structure
struct gameSave;
 int lifepoints;
 int mapX;
 int mapY;
end

// Put data in it
gameSave.lifePoints = 100;
gameSave.mapX = 4;
gameSave.mapY = 7;

// Write it to a file
save("data.sav", gameSave);

// Read it from a file
load("data.sav", gameSave);
Hope this helps, and if all else fails, pay http://fenixonfire.gp32x.de a visit when it re-opens.

- Alex
thanks, that'll be fine, I knew how to save and load variables, just not how to do structs.
 
Last edited by a moderator:
I forgot to add this, how you load from the structure into the game:

Code:
// Read it from a file
load("data.sav", gameSave);

// in-game variables
int lifePoints;
int mapX;
int mapY;

// populate them from the loaded struct
lifePoints = gameSave.lifePoints;
mapX = gameSave.mapX;
mapY = gameSave.mapY;
You probably knew how to do this already though :)

- Alex
 
Back
Top