Game Editor: Map data structure

  It's helpful to know how maps are stored in a level. And it's also helpful to know the contents of the map movieClip. Below, I'll show the structure of both.

Key
  (object)
[array]
_[x]
__y =
variable
variable_mc
variable_pic

Map data structure
 

It's helpful to know how maps are stored in a level. This object is what you would send to a map to make it draw something.
Since the map can store multiple layers of tiles, the "layer" array contains multiple 2-dimensional arrays, one for each layer. Each 2-dimensional array stores the tiles for that layer. The numbers assigned to the various "y" positions refer to tile image ID's in the chipset. So the map system looks at this number and knows which tile in the chipset to display.
The zeros and ones in the collision array refer to collision ID's. Zero ususally represents open space, and One usually represents walls. Other values are treated differently by different games.

When map and level files are saved, some of the map data is stored in a different way to reduce filesize. The maps in these files will have their "format" variable set to 2. The level editor de-compresses the data into the structure you see here and sets the "format" variable to 1. When it saves a file, it stores the map data in compressed format. Games typically leave the data in compressed format and simply send the compressed data to the map system, which can display both formats.
The newer Map3 format handles this differently.

(map)
format = 1__(1 = un-compressed data. 2 = compressed data)
width = 20__(the map width, in tiles)
height = 15__(the map height, in tiles)
chipset = "chipset/basis.png"
[layers]__(there can be up to 9 layers)
[0]
[x]
y = 214
y = 16
y = 0
[1]
[x]
y = 214
y = 16
y = 0
[collision]
[x]
y = 0
y = 0
y = 1
y = 0


Map movieClip structure
  When the map system loads the above data, it'll create a movieClip with the following structure.
It's useful to understand the contents in order to access things like collision data. This movieClip also contains some useful functions, which are explained in the comments at the top of map.as.
(map_mc)
(layer0_mc)
layer0_pic
(layer1_mc)
layer1_pic
width = 20__(the map width, in tiles)
height = 15__(the map height, in tiles)
chipset_pic
[collision_array]
[x]
y = 0
y = 0
y = 1
y = 0


Last updated: December 27, 2014