How do I make a save file?

Started by
3 comments, last by daviangel 15 years, 9 months ago
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! ^__^
Advertisement
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.
There was a saying we had in college: Those who walk into the engineering building are never quite the same when they walk out.
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.
Oh... Easy! Thank you very much! :)
Here's an example in Allegro showing Loading, Saving and Diplaying a Map that should give you some ideas.
[size="2"]Don't talk about writing games, don't write design docs, don't spend your time on web boards. Sit in your house write 20 games when you complete them you will either want to do it the rest of your life or not * Andre Lamothe

This topic is closed to new replies.

Advertisement