Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

graveyard filla

implementing a save() and load() game functions????

This topic is 5307 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

high, ive been thinking about this question for a little bit. now that ive expanded my ascii RPG to be able to play as many levels as maps i can make, ive thought about putting in a save/load game feature. so how does this work exactly? just thiking about it, it seems like it wont be that hard. all i have to do is let the user pause the game during play (or when you first start the game). once at this paused screen, ill give the user the choice to load or save a game. if they pick save, what i would do was take all of the important game data- like health,stamina,mana, x and y position, current level, items they have, ETC. and output all this information to a txt file. then, if they later chose the load option, it would read in each of these variables in from the txt file , and then plug those variables in into the current games data. effectively putting the user in the same "state" as they were in when they saved the game. it seems like this wouldnt be that hard to do, i would just have to make sure to include all the important variables that need to be saved. is this all there is to it? anything i might need to know ahead of time so i dont screw anything up bad? thanks for any help

Share this post


Link to post
Share on other sites
Advertisement
Not quite sure how your game works, but you might need to save weapon states, spell states, enemy states. Anything of that nature.

If you derive all entities from a base class and store all of the entities in the list, why don''t you give the class a ''Save'' function?

Then you just loop through the entity list calling the save function. That way everything thats currently in-game (in your entity list) is saved.

Share this post


Link to post
Share on other sites
Yep, that''s how it works! Just be sure you put everything, that means EVERYTHING, the game needs to know in order to restore the game to the exact point that it was when the user saved.

Share this post


Link to post
Share on other sites
Normally a game has a game state, a tree structure with all objects in them. Anything that can change needs to be in there. Then when saving or loading it can be easily be rebuilt.

Share this post


Link to post
Share on other sites
quote:
Original post by graveyard filla
... and output all this information to a txt file. then, if they later chose the load option, it would read in each of these variables in from the txt file


I have found that saving in binary mode is generally easier than saving in text mode. That is how most (pro) games do it anyway. Text mode allows users to easily edit the save file... which may or may not be a good thing.

I read this article a few days ago. It may help you. I do saving and loading in a somewhat similar fashion in my game.


James Sayer
Dingo Games
www.dingogames.com
Home of Jack of All Trades

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!