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

Started by
11 comments, last by dsm1891 11 years ago

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

Mobile Developer at PawPrint Games ltd.

(Not "mobile" as in I move around a lot, but as in phones, mobile phone developer)

(Although I am mobile. no, not as in a babies mobile, I move from place to place)

(Not "place" as in fish, but location.)

Advertisement

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.

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

Mobile Developer at PawPrint Games ltd.

(Not "mobile" as in I move around a lot, but as in phones, mobile phone developer)

(Although I am mobile. no, not as in a babies mobile, I move from place to place)

(Not "place" as in fish, but location.)

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.

do! develop! create! - visit my scripters-corner.net

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.

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

Mobile Developer at PawPrint Games ltd.

(Not "mobile" as in I move around a lot, but as in phones, mobile phone developer)

(Although I am mobile. no, not as in a babies mobile, I move from place to place)

(Not "place" as in fish, but location.)

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 :)

Mobile Developer at PawPrint Games ltd.

(Not "mobile" as in I move around a lot, but as in phones, mobile phone developer)

(Although I am mobile. no, not as in a babies mobile, I move from place to place)

(Not "place" as in fish, but location.)

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.

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

Mobile Developer at PawPrint Games ltd.

(Not "mobile" as in I move around a lot, but as in phones, mobile phone developer)

(Although I am mobile. no, not as in a babies mobile, I move from place to place)

(Not "place" as in fish, but location.)

...

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.

void hurrrrrrrr() {__asm sub [ebp+4],5;}

There are ten kinds of people in this world: those who understand binary and those who don't.

This topic is closed to new replies.

Advertisement