# Good map file structure?

I need a map file structure for my game but does anyone know a good way to map it out? I was thinking something like this:

name=MyMap


Planning on making these map files by hand? You have 409,599 more lines to write if you want to fill a 640x640 tiled map.

You should store the map in a binary format. An easy way to do that is to serialize the data structure you're storing the map with in RAM.

It would be far easier to write a simple visual editor that allowed you to place tiles and write a binary file, than to write out so many lines by hand.

• I'm making a level editor. Jan 28 '13 at 8:30

Depending on what you are going to do for a game, this is diffrent. In other words, An fps, might store additional stuff on the map like, monsters, spawn points of monsters, pickups, and more.

While a RTS might only store, the diffuculty to move there, the tile, and what kind of protection this tile gives.

But you structure there looks wery promising. seems like it will be easy to just add up stuff. and easy to remove stuff. And flexibility is allways a good choise.

I'd recommend you the XML format and, specifically for the tiles, you can try to put just the tile number, something like this:

<Map>
<Tiles> 0 10 2 3 4 5...
.
.
.
</Tiles>

<CollisionLayer>
0 0 1 1 0 0...
.
.
.
</CollisionLayer>

<BlendLayer>
.
.
.
<BlendLayer>
</Map>


This depends on various points. Since you didn't really go in-depth with your current setting (game-type, platform, etc.), all I can do here is do assumptions.

1. ### The dimension

2D vs. 3D, the probably biggest aspect. While storing a pure 2D map (even if it has multiple layers) as a text-like file is still possible, doing the same with a 3D file would be madness.

As an example, the UDK example map "Day and Night" is 189214 kb big. If you were to type every byte per hand, this would take ~150 hours in total, given that you can type 6 days straight without pause.

So clearly, if you aim to create a 3D map, don't even think about creating those by hand.

2. ### The game type

Various different games require different features. For example:

• A side-scrolling shooter requires lot of spawn-points for enemies and practically one big background-image, but the player is practically in a moving box.
• A jump 'n' run might be built like a list with "blocks" and other things in it.
• A "Pokémon"-like RPG with a grid, multiple layers and events could quickly go beyond everything you want to write by hand and you'd end up writing your own map-creator tool in the process of development.
3. ### The platform

I have no idea what platform you're working on, PC, Mac, iPhone, Android, GBA, etc., but I have to inform you that various gaming platforms already have either established game SDK's or Frameworks, such as GameKit for iOS, which already comes with every XCode install.

Do a Google-search for your platform and maybe ask around to see which frameworks fit your game and platform. While I do encourage you to do things on your own as you begin, seeing how "pros" do things can't hurt. (E.g. it helped me a lot to see how notch stores his blocks in Minecraft.)

4. ### The tools

Depending on the size of your game, you might feel the need arise to add a map editor to your game. Not just for the user, but also for yourself! I mean, if you write a set of ten maps, each consisting of a 25 x 25 x 1 tiles, then you could do it by hand, but as soon as events, layers and other more advanced things come in, I strongly advise to create such a tool.