Sign in to follow this  
dsm1891

Saving Game Data (map, entities, progression etc.)

Recommended Posts

dsm1891    2746

Hello,

 

So i find myself (roughly) designing a simple(ish) 2D engine and was wondering what is the best way(s) of storing all types of game data is? granted there will be plenty of options, but are there any you would suggest?

 

 

In the past I have always wrote variables to a text file to store them, then read that file to store them back to said variable, but when working with hundreds of different entities, each with different parameters, that can get a little sloppy. I have also worked with SQL Light and XML (android), and I can see how useful SQL light can be by storing entity data, and likewise with storing level data in XML.

 

 

However I am working with c++ now and have no experience (other than the reading and writing to text file) in the saving game data area.

 

I posted this in the beginners section, but all answers will be appreciated

 

Thanks smile.png

 

Share this post


Link to post
Share on other sites
dsm1891    2746

If the game is simple, you can use the .ini file format. Editing is also simple, because it can be done with a text editor.

Thanks, I know A LOT of games use ini, but honestly have never edited one, what are the advantages? surley if it is simply writing values to the file, i will come across the same uglyness of writing to a txt file and again can easily get a little sloppy.

 

Are there any good web-tutorials on ini? quick google, didnt really show any promises :/

 

Thanks though

Share this post


Link to post
Share on other sites
redw0lf    334

In my opinion there is not a general answer to this. Use what you like the most or what you are most experienced with. Also I think the answer to the question highly depends on what you are doing with the data and what kind of data you are using. Another question would then be if it there is an easy API to support the programming. 

 

As far as I'm concerned I like to use of database especially the nosql databases are quite handy to store data fast. E.g. MongoDb or djondb. You have the benefit that you do not have to think about on how  to structure your data as you would have in an sql database you can easily store and restore them.

Share this post


Link to post
Share on other sites
Froyo    201

If the game is simple, you can use the .ini file format. Editing is also simple, because it can be done with a text editor.

Thanks, I know A LOT of games use ini, but honestly have never edited one, what are the advantages? surley if it is simply writing values to the file, i will come across the same uglyness of writing to a txt file and again can easily get a little sloppy.

 

Are there any good web-tutorials on ini? quick google, didnt really show any promises :/

 

Thanks though

You shouldn't need a tutorial to make INI files, they're pretty simple and informal. They're just plain text files with name-value pairs.

 

http://en.wikipedia.org/wiki/INI_file

 

As far as integrating it with C++, just stream to write/read file from the file.

Share this post


Link to post
Share on other sites
dsm1891    2746

You shouldn't need a tutorial to make INI files, they're pretty simple and informal. They're just plain text files with name-value pairs.



http://en.wikipedia.org/wiki/INI_file



As far as integrating it with C++, just stream to write/read file from the file.

 

oh really? so its a bit like XML with tags (well, atleast the sections)?

I'll look into it thanks!

 

But anyone else feel free to leave other suggestions smile.png

Edited by dsm1891

Share this post


Link to post
Share on other sites
dsm1891    2746

In my opinion there is not a general answer to this. Use what you like the most or what you are most experienced with. Also I think the answer to the question highly depends on what you are doing with the data and what kind of data you are using. Another question would then be if it there is an easy API to support the programming. 

 

As far as I'm concerned I like to use of database especially the nosql databases are quite handy to store data fast. E.g. MongoDb or djondb. You have the benefit that you do not have to think about on how  to structure your data as you would have in an sql database you can easily store and restore them.

Hey, Thanks, we have an advantage on our team, we have a person who use to design and make sql databases for a living, :) but ill look into those two databases you suggested

 

Thanks again :)

Share this post


Link to post
Share on other sites
Daerst    307

It may be an overkill, but you could take a look at the Boost::serialization library. This will directly serialize your C++ classes and save them to a file, to be deserialized later. Useful for savegames, though I would not suggest using it for game resources like dialogs, maps etc. You need something more readable here.

 

What editors do you use to build your content? Self-made or 3rd party? I use the Tiled editor on a 2D project, thus the engine needs to be able to read the format understood by the tool.

Share this post


Link to post
Share on other sites
dsm1891    2746

It may be an overkill, but you could take a look at the Boost::serialization library. This will directly serialize your C++ classes and save them to a file, to be deserialized later. Useful for savegames, though I would not suggest using it for game resources like dialogs, maps etc. You need something more readable here.

 

What editors do you use to build your content? Self-made or 3rd party? I use the Tiled editor on a 2D project, thus the engine needs to be able to read the format understood by the tool.

Thanks for the suggestion , ill look into it.

 

We are leaning towards making our own tile editor, but depending on time, we might just use a free one of the internet

Share this post


Link to post
Share on other sites
Khatharr    8812

...

 

A file is a file. Learn to serialize your data using whatever method is comfortable for you. It's not hard. Just think about the process used to restore the data and store things in a way that will make that easy.

Share this post


Link to post
Share on other sites
dsm1891    2746

I know, i just wondered if anybody had any better methods :/

...

 

A file is a file. Learn to serialize your data using whatever method is comfortable for you. It's not hard. Just think about the process used to restore the data and store things in a way that will make that easy.

Share this post


Link to post
Share on other sites
dsm1891    2746

If you're already familiar with XML then I'd suggest a library such as TinyXML.  It's a C++ library for reading and writing data with XML files.

Really? thanks for the link!! was googling for a while for such a library! Thanks! :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this