How do I make a save file?
I'm wondering how to make a file that my program can read to pick up where the game left off.
I am using Allegro and C++
Example:
Start game, choose New Game or Continue Game.
I want game to remember variables such as map, saveroomid, has_so_and_so_weapon_unlocked, defeated_whatever_boss...
Please help me! ^__^
Well, first you should learn how to do file I/O if you haven't already. Then, decide on a format for the file (in this case, what to save, and in what orderr). Then its a matter of writing these values to a file in the given order with something left in there to deliminate where one value ends and the next begins. Loading them is a matter of reading in up to each deliminator and copying the value into the appropriate variable in the right order.
This is a very simple version of a very limited method, I don't have time to write too much more, hopefully it will help.
This is a very simple version of a very limited method, I don't have time to write too much more, hopefully it will help.
Generally your game will have state variables and such, a really simple way, is to simply write all that data to file, then to load, just read it in the same order assigning them to the variables state variables.
Here's an example in Allegro showing Loading, Saving and Diplaying a Map that should give you some ideas.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement