Actionscript:
-
var col:Array = [0x000000, 0xCCCCCC, 0xFF0000, 0xCCCC00, 0x000055, 0x00CCCC];
-
-
var map:Array = new Array();
-
map[0] = [0,0,0,0,0,0,0,0,0,0];
-
map[1] = [0,0,0,0,0,0,0,0,0,0];
-
map[2] = [0,5,4,5,4,5,4,5,4,0];
-
map[3] = [0,4,4,4,4,4,4,4,4,0];
-
map[4] = [0,4,0,0,0,0,0,0,4,0];
-
map[5] = [0,3,2,3,2,3,2,3,2,0];
-
map[6] = [1,1,1,1,1,1,1,1,1,1];
-
map[7] = [0,2,2,2,2,2,2,2,2,0];
-
map[8] = [1,1,1,1,1,1,1,1,1,1];
-
-
for (var i:int = 0; i<map.length; i++){
-
for (var j:int = 0; j<map[i].length; j++){
-
graphics.beginFill(col[map[i][j]]);
-
graphics.drawRect(j * 10, i * 10, 10, 10);
-
}
-
}
Use a 2D array to draw a map of colored rectangles. Lots of stuff you can do with this - like adding game tiles instead of drawing colored rects:
Actionscript:
-
// add clip with multiple frames - each containing a tile graphic
-
var tile:MovieClip = TileClip();
-
tile.gotoAndStop(map[i][j]+1);
-
addChild(tile);