Need help creating save/loading system.

Please support our Game Development advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Nov 2008
Posts: 29
Reputation: Shinedevil is an unknown quantity at this point 
Solved Threads: 0
Shinedevil Shinedevil is offline Offline
Light Poster

Need help creating save/loading system.

 
0
  #1
Dec 6th, 2008
I have no idea how to make somthing like this, and i'm kind of new with file I/O.
How would you start somthing like this?

O.k. here is what I have to save,
I have roughly 56+ variables that need to be counted in this.
But what I am having trouble with is when you write in a word doc it can't save the actual vairable values.
I need to save like if somthing is 1 or 0. Like if you equiped a weapon or not, or if a quest if active. And then acess that when you load the game back up, but I can't seem to get the variable to show up when you access the load screen so the game locks up when you access portions of the map that "are not acessed yet." Which should have been saved during the previous play.
(it's also annoying when you have to start over agian when you start up the game)
For example,
int x;
x = x + 1;
I need to save the value of x, being that it is a coordinate to the map, and load it from the file agian exactly as it saved it.

Anybody know how to do this, or at least give me a brief walkthrough with file I/O and or how to access and save to files?

Here is an example of two code snippets;
{
loadgame:
savefile1.open ("savefile1.txt", ios::out | ios::app);
savefile1.close();
goto maptest;
}
{
save:
savefile1.open ("savefile1.txt");
savefile1 <<"x ="<<x<<"\n"<<"y ="<<y<<"\n";
savefile1.close();
goto jumpto;
}
could someone tell me how to access those x and y variables?
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 974
Reputation: MosaicFuneral is just really nice MosaicFuneral is just really nice MosaicFuneral is just really nice MosaicFuneral is just really nice MosaicFuneral is just really nice 
Solved Threads: 92
MosaicFuneral's Avatar
MosaicFuneral MosaicFuneral is offline Offline
Posting Shark

Re: Need help creating save/loading system.

 
0
  #2
Dec 17th, 2008
One way would be getline getline(file, string); , or using >> file >> x; file >> y; file whatever; , if your data is in a fixed format.

Why are you using gotos?!...
"Jedenfalls bin ich überzeugt, daß der Alte nicht würfelt."
"I became very sensitive to what will happen to all this and all of us." -Two geniuses named Albert
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for Game Development
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC