Best way to save level data

Started by
20 comments, last by henthoven 19 years, 11 months ago
Hi, The last few weeks I have been working on a side scrolling platform game. I am verry happy with the result I have at the moment. But I am not very happy with the way I save and load the level data for the different levels. At the moment level data is saved in a textfile. In this file the first lines tell the size of the level and some other information. Then I have a table with komma sepperated integers that that represent the level data. So, it looks as something like this: 10 // width 5 // height 0,0,0,0,0,0,0,0,0,0, 0,3,0,0,0,0,0,0,3,0, 0,3,0,0,0,1,0,0,3,0, 0,0,0,0,1,1,1,0,0,0, 1,1,1,1,1,1,1,1,1,1, Well, I don''t think this is a very good way, or is it? Is there someone who can advise me a good solution? Thanks in advance! Regards, Hans. By the way, if you would like to see the game, it can be found at http://www.pottum.nl/manzana/.
Advertisement
binary?
3D Side-Scroller game demo Project-X2 "playable"Lashkar: A 3D Game & Simulation Project demo @ lashkar.berlios.de
Sadly, your game doesn''t run. For like a split-second you can kinda see a window, but then it disappears and the game crashes.
Since I saw you are using Allegro: check the docs for the packfile-functions!

Indeterminatus--si tacuisses, philosophus mansisses--
Apart from the packfile idea - I don''t see any simpler way to easily store the data for your type of game
Hi,

Thanks! I am gonna checkout what a packfile is, maby I can use it.
For that anonymous user, strange that it doesn''t run. Did you unpack the files including the subdirs? There should be 4 files in a dir called ''data''. These files are menu.dat, level1.dat, level2.dat, level3.dat and game.hs.
Hopefully this will help.

Regards,

Hans.
Hello,

You may want to have a look at Mappy, at http://www.tilemap.co.uk/mappy.php - it''s an editor for tile-based games, and has a library which you can use in allegro for drawing your map to screen.

Hope this helps

Pete

Why you shouldn''t use iostream.h - ever! | A Good free online C++ book
Ok, thanks, I also check out mappy!
But I also had another idea. Is it a good idea to just serialize a level object to a file and unserialize it when the level must be loaded. In that way a level editor could be made very easy because you only have to make an instance of a level object, set all the values and then serialize it to a file.
In the game the level can be loaded by unserializing the file.

Is this a good idea and is it easy in C++ to serialize and unserialize an object?
I hope someone has experience with this and can tell me more about it. Thanks in advance!

Regards,

Hans.
I''m not sure if serialization is a good way to go for games so I won''t comment.

I did try out your game though and it worked perfectly. Keep up the good work!
make a level data structure and save it with fwrite

This topic is closed to new replies.

Advertisement