2D Tile Map files for Platformer, JSON or DB?
- by Stephen Tierney
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.
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: 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