| | |
Need help creating save/loading system.
Please support our Game Development advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Nov 2008
Posts: 29
Reputation:
Solved Threads: 0
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;
could someone tell me how to access those x and y variables?
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;
} One way would be getline
Why are you using gotos?!...
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
"I became very sensitive to what will happen to all this and all of us." -Two geniuses named Albert
![]() |
Similar Threads
- Lost Windows XP user password (Windows NT / 2000 / XP)
- javax.crypto.BadPaddingException and Properties (Java)
- memory management in wndows 2000 (Windows NT / 2000 / XP)
- Source Code that don't work? (Java)
- Hey check out my prog. It has an error can u find it? (Java)
- Help with a reservation program! GUI Messed XD (Java)
- Java.io help!!! (Java)
Other Threads in the Game Development Forum
- Previous Thread: shooting game
- Next Thread: Space Invaders game (C# & OpenGL)
| Thread Tools | Search this Thread |
Tag cloud for Game Development
3d advertising ai algorithm ban c++ cambridge camera censorship china competition console development engine fov fpx game gamedevelopment gameprogramming gamer games gaming gauntanamo government graphics idaho in-gameadvertisement intel intellectualproperty l-systems laracroft larrabee lindenmayer live manhunt math mathematics matrix mercenaries microsoft mmorpg modded msn multicore naked news nintendo obama opengl palin physics pirate playstation politics processor projection ps3 rpg search selection software sony stephenhawking stocks studio technology terrorism tombraider uk videogame web wii world-of-warcraft xbox xbox-live xbox360





