Roycommi
08-06-2003, 03:18 PM
Hi,
I am trying to figure out how to do tile based games so I am following the examples on outsideofsociety.idz.net .
At any rate, I am a bit confused at a bit in the first example: drawing a map. Here is the code:
fscommand ( "allowscale", false );
myMap = [ [1,1,1,1,1,1,1,1],
[1,0,0,0,0,0,0,1],
[1,0,1,0,0,0,0,1],
[1,0,0,0,0,1,0,1],
[1,0,0,0,0,0,0,1],
[1,1,1,1,1,1,1,1] ];
tileW = 24;
tileH = 24;
boarder = 001.bmp;
function buildMap (map) {
var mapWidth = map[0].length;
var mapHeight = map.length;
for (var L = 0; L<mapHeight; ++L) {
for (var w = 0; w<mapWidth; ++w) {
this.attachMovie("tile", "t_"+L+"_"+w, ++d);
this["t_"+L+"_"+w]._x = (w*tileW);
this["t_"+L+"_"+w]._y = (L*tileH);
this["t_"+L+"_"+w].gotoAndStop(map[L][w]+1);
}
}
}
buildMap (myMap);
I do not understand what mechanism here actually says "if array component (x,x) = 1 then paint it black, else paint it white"
I am new to Flash MX and actionscript so i imagine there is a fundamental part I am missing.
Thanks in Advance!!
Roycommi
I am trying to figure out how to do tile based games so I am following the examples on outsideofsociety.idz.net .
At any rate, I am a bit confused at a bit in the first example: drawing a map. Here is the code:
fscommand ( "allowscale", false );
myMap = [ [1,1,1,1,1,1,1,1],
[1,0,0,0,0,0,0,1],
[1,0,1,0,0,0,0,1],
[1,0,0,0,0,1,0,1],
[1,0,0,0,0,0,0,1],
[1,1,1,1,1,1,1,1] ];
tileW = 24;
tileH = 24;
boarder = 001.bmp;
function buildMap (map) {
var mapWidth = map[0].length;
var mapHeight = map.length;
for (var L = 0; L<mapHeight; ++L) {
for (var w = 0; w<mapWidth; ++w) {
this.attachMovie("tile", "t_"+L+"_"+w, ++d);
this["t_"+L+"_"+w]._x = (w*tileW);
this["t_"+L+"_"+w]._y = (L*tileH);
this["t_"+L+"_"+w].gotoAndStop(map[L][w]+1);
}
}
}
buildMap (myMap);
I do not understand what mechanism here actually says "if array component (x,x) = 1 then paint it black, else paint it white"
I am new to Flash MX and actionscript so i imagine there is a fundamental part I am missing.
Thanks in Advance!!
Roycommi