2
\$\begingroup\$

I am currently working on a terminal text game just to practice my skills (C). It will be story driven escape the mansion kind of game. Even though the game will be short I want it to support save files.

Since I am new to game programming I am not sure how should I handle save files. The game will be short yet players will be able to find a lot of objects. I was thinking about saving a structure into a .txt file OR saving lots of 1 and 0 into txt file. Where each line represents each item or progress.

Is there a better way or common way how to do it?

\$\endgroup\$
2
  • 2
    \$\begingroup\$ If I understand it right, you want to save just binary information - object was found X object wasn't found? \$\endgroup\$
    – zacharmarz
    Dec 23, 2011 at 12:06
  • \$\begingroup\$ Did you use the LibGDX engine? It has the object called "Preferences" that allows you to save and load game? If not, what kind of game engine did you used for making game apps? \$\endgroup\$ Jan 29, 2013 at 4:50

3 Answers 3

5
\$\begingroup\$

Saves do not usually need readability, so it's good to save them binary format. If object interactive, you should save all non-calculated fields to file, as I suppose you have multiple locations. So there will be saves for each location and hero saves (inventory, active tasks). There are many related questions. related topic

\$\endgroup\$
1
  • \$\begingroup\$ That depends on the IDE and a game engine implemented onto the IDE when you're programming a game. \$\endgroup\$ Jan 29, 2013 at 4:51
0
\$\begingroup\$

From my small experience, one of the best ways of saving a game is using XML. You can see what is happening, you can change the save files, you can even prepare then to be used for map editors. Finally, in the end, you could always put then in the binary form.

\$\endgroup\$
2
  • 1
    \$\begingroup\$ Wouldn't you have to include an external xml library to generate / parse? Also, people could manually alter the variables? \$\endgroup\$
    – SSH This
    Jul 25, 2012 at 21:07
  • \$\begingroup\$ A open source, with commercial license in applied-mathematics.net/tools/xmlParser.html can be found. A binary can avoid people change if you don't want to. \$\endgroup\$ Jul 25, 2012 at 21:36
0
\$\begingroup\$
fprintf( fd, "format",  ...); /*save*/
fscanf( fd, "format", ...); /*load*/

Where ... represents variables and "format" describes how they are formatted.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .