Game Editor: Map3 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. Each tile is an object that contains a "chipset" "x" and "y" variable. These variables are used to look-up the tile image located at the coordinate specified by "x" and "y". And the "chipset" vairable is an index number that refers to one of the files in the [chipsets] array. Therefore each tile can use a completely different chipset.
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 "isCompressed" variable set to "true". The level editor de-compresses the data into the structure you see here and sets the "isCompressed" variable to "false". 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 older Map format handles this differently.

(map)
format = 3__(This map format is always labeled as 3)
isCompressed = false__(This data is un-compressed. Files are compressed)
width = 20__(the map width, in tiles)
height = 15__(the map height, in tiles)
tileSize = 16__(the width & height of each tile, in pixels)
[chipsets]__(there can be up to 36 chipsets)
0 = "chipset/basis.png"
1 = "chipset/pokemon.png"
2 = "chipset/zelda.png"
[layers]__(there can be up to 9 layers)
[0]
[x]
[y]
chipset = 0__(chipset index. This one refers to basis.png)
x = 4__(this tile's horizontal coordinate in the chipset, in tiles)
y = 12__(this tile's vertical coordinate in the chipset, in tiles)
[1]
[x]
[y]
chipset = 2__(chipset index. This one refers to zelda.png)
x = 35__(coordinates can be between 0 and 35)
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 map3.as.
(map_mc)
(layer0_mc)
pic = BitmapData__(image data being displayed by layer0_mc)
(layer1_mc)
pic = BitmapData__(image data being displayed by layer1_mc)
[layers_mc_array]
[0]__(reference to layer0_mc movieClip)
[1]__(reference to layer1_mc movieClip)
[2]__(reference to layer2_mc movieClip)
[chipset_mc_array]
[0]
file = "chipset/basis.png"__(path to an image file)
pic = BitmapData__(image data of basis.png)
[1]
file = "chipset/pokemon.png"__(path to an image file)
pic = BitmapData__(image data of pokemon.png)
[collision_array]
[x]
y = 0
y = 0
y = 1
y = 0


Last updated: December 27, 2014