I'm trying to make a tile-based strategy game. I've never done tile-based before, so I'm kinda lost.
Here's what I have:
as it is, it doesn't work because I can't seem to figure out how to randomly generate a 10x10 terrain. I know it has something to do with for-loops, but i don't know how to put a random number(0 or 1) into the map array.Code:map = new Array(10,10); tileW = 40; tileH = 40; function buildMap (map1) { var mapWidth = map1[0].length; var mapHeight = map1.length; for (var i = 0; i<mapHeight; ++i) { for (var j = 0; j<mapWidth; ++j) { this.attachMovie("tile", "t_"+i+"_"+j, ++d); this["t_"+i+"_"+j]._x = (j*tileW); this["t_"+i+"_"+j]._y = (i*tileH); this["t_"+i+"_"+j].gotoAndStop(map1[i][j]+1); } } } buildMap(map);
any help is appreciated
thanks




Reply With Quote