Jump to content

  • Log In with Google      Sign In   
  • Create Account


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


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
12 replies to this topic

#1 dsm1891   Crossbones+   -  Reputation: 1211

Like
3Likes
Like

Posted 04 April 2013 - 03:54 PM

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

 



Sponsor:

#2 ultramailman   Prime Members   -  Reputation: 1563

Like
0Likes
Like

Posted 04 April 2013 - 04:09 PM

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.



#3 dsm1891   Crossbones+   -  Reputation: 1211

Like
1Likes
Like

Posted 04 April 2013 - 04:15 PM

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



#4 redw0lf   Members   -  Reputation: 284

Like
1Likes
Like

Posted 04 April 2013 - 04:23 PM

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


#5 Froyo   Members   -  Reputation: 201

Like
0Likes
Like

Posted 04 April 2013 - 04:44 PM

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.



#6 dsm1891   Crossbones+   -  Reputation: 1211

Like
0Likes
Like

Posted 04 April 2013 - 04:53 PM

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, 04 April 2013 - 04:53 PM.


#7 dsm1891   Crossbones+   -  Reputation: 1211

Like
0Likes
Like

Posted 04 April 2013 - 04:56 PM

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



#8 Daerst   Members   -  Reputation: 227

Like
0Likes
Like

Posted 05 April 2013 - 02:42 AM

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.



#9 dsm1891   Crossbones+   -  Reputation: 1211

Like
0Likes
Like

Posted 05 April 2013 - 02:54 AM

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



#10 Khatharr   Crossbones+   -  Reputation: 2974

Like
0Likes
Like

Posted 06 April 2013 - 09:22 PM

...

 

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.

#11 dsm1891   Crossbones+   -  Reputation: 1211

Like
0Likes
Like

Posted 07 April 2013 - 01:20 PM

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.



#12 LennyLen   Crossbones+   -  Reputation: 3756

Like
0Likes
Like

Posted 07 April 2013 - 01:37 PM

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.



#13 dsm1891   Crossbones+   -  Reputation: 1211

Like
0Likes
Like

Posted 07 April 2013 - 01:39 PM

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






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS