Archived

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

Seriema

How to make "save game"??

Recommended Posts

Hi! I''m working on a simple RPG with DX8.1 and C++. I''m very curious on one thing though!! When you save your game, how is it saved?? Technicly that is? I''m thinking of a database with a lot of posts, is it like that? Do any of you have a good link or tutorial or source code to look at? }+TITANIUM+{

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I''m not sure if I understand you correctly, but what normally happens, is your program will open up a text file, print a bunch of numbers and states, and close the file. Ie:
SAVE: "Badly hurt"
HP:25
MAXHP:40
MANA:10
MAXMANA:11
LEVEL:20
ATTACKPOW:5
DEFENSEPOW:4
MAP: "town.map"
XLOC: 5
YLOC: 5
ENDSAVE

This is basically what a normal save game would look like. for debugging purposes, leave it in normal text, but when you are finished, change to binary.

Share this post


Link to post
Share on other sites
It''s all dependent upon the way your game is set up (as usual).

Since it''s an RPG, it depends upon whether it''s linear or not. If it''s linear, you could generally save the stats and the current position in the storyline (and whatever flags you carry throughout the game that might affect later play). If it''s nonlinear, you''ll need to store each and every little thing that happens that could affect the outcome later on (I did this quest, didn''t do this quest, said this thing here but contradicted it later, etc.).

For the linear case, it''d be just as easy to save the results to a file, as the AP suggested. If it''s nonlinear, then you MAY want to use a DB type of system internally for saving what''s been done (or not done) and then just dumping that state to a file when you want to save. Then you can just load up the state of the DB and continue on like nothing has happened.

Share this post


Link to post
Share on other sites
I''d go with the latter, the db solution.

If it''s an RPG, you should simply keep track of everything in a db (even comma or tab delimited if you want), that way everything is in a constant state of updating. If you want to save the game all you have to do is simply make copies of those files as they stand at that point in time.

Easy as pie.

Share this post


Link to post
Share on other sites
Could anyone suggest reading matterial relating to the db approach? I''ve been puzzling over a similar problem lately for a non-linear game.

-OOProgrammer

Let the noob-flaming begin!

Share this post


Link to post
Share on other sites
quote:

Could anyone suggest reading matterial relating to the db approach? I''ve been puzzling over a similar problem lately for a non-linear game.




You could use a simple key/value scheme. You have a table with two columns: one is a text field for the key name, the other is a text field for the value. Make a list of the data itmes you want to save, give each item a unique key name, then write that and the value out. For instance, a player''s hit points might have a key of "pl_hp" and a value of "65". His location could be stored in the key "pl_loc" with a value of "65,23".
The only bad thing about this is that all your data has to be text.
Of course, it''s easy to extend the idea, to have multiple value types. You''d have a string table, int table, whatever. Each would have a key column, and then a column of the appropriate type. Your read/write functions would take the type into account, such as "WriteStringValue(string& key, string& value)" and "WriteIntValue(string& key, int value)"

Just a thought.

Take care,
Bill

Share this post


Link to post
Share on other sites
Thanks for the suggestion. I think I''ve figured out most things now...it''s just a matter of deciding how to handle conditional scripts in dialogue trees and a few other places now. If I get that far. :D

-OOProgrammer

Let the noob-flaming begin!

Share this post


Link to post
Share on other sites