I'm developing a 2D platformer with some uni friends. We've based it upon the XNA Platformer Starter Kit which uses .txt files to store the tile map. While this is simple it does not give us enough control and flexibility with level design. Some examples: for multiple layers of content multiple files are required, each object is fixed onto the grid, doesn't allow for rotation of objects, limited number of characters etc. So I'm doing some research into how to store the level data and map file.
This concerns only the file system storage of the tile maps, not the data structure to be used by the game while it is running. The tile map is loaded into a 2D array, so this question is about which source to fill the array from.
Reasoning for DB: From my perspective I see less redundancy of data using a database to store the tile data. Tiles in the same x,y position with the same characteristics can be reused from level to level. It seems like it would simple enough to write a method to retrieve all the tiles that are used in a particular level from the database.
Reasoning for JSON/XML: Visually editable files, changes can be tracked via SVN a lot easier. But there is repeated content.
Do either have any drawbacks (load times, access times, memory etc) compared to the other? And what is commonly used in the industry?
Currently the file looks like this:
....................
....................
....................
....................
....................
....................
....................
.........GGG........
.........###........
....................
....GGG.......GGG...
....###.......###...
....................
.1................X.
####################
1 - Player start point, X - Level Exit, . - Empty space, # - Platform, G - Gem
std::vector
can do that job a lot better than a relational database. RDBs are for large datasets that you intend to search in various, varying, and complex ways. They are optimized for that kind of data usage, which is why they have complex query mechanisms. – Nicol Bolas Nov 12 '11 at 02:42