Ik ben nu begonnen met het leren hoe je tile based games maakt, maar ik zit met vragen over de code.
actionscript codemyMap = [[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]];
game = {tileW:30, tileH:30};
char={xtile:2, ytile:1, speed:4};
game.Tile0 = function() {
};
game.Tile0.prototype.walkable = true;
game.Tile0.prototype.frame = 1;
game.Tile1 = function() {
};
game.Tile1.prototype.walkable = false;
game.Tile1.prototype.frame = 2;
function buildMap(map) {
_root.attachMovie("empty", "tiles", ++d);
game.clip = _root.tiles;
var mapWidth = map[0].length;
var mapHeight = map.length;
for (var i = 0; i<mapHeight; ++i) {
for (var j = 0; j<mapWidth; ++j) {
var name = "t_"+i+"_"+j;
game[name] = new game["Tile"+map[i][j]]();
game.clip.attachMovie("tile", name, i*100+j*2);
game.clip[name]._x = (j*game.tileW);
game.clip[name]._y = (i*game.tileH);
game.clip[name].gotoAndStop(game[name].frame);
}
}
game.clip.attachMovie("char", "char", 10000);
char.clip = game.clip.char;
char.x = (char.xtile*game.tileW)+game.tileW/2;
char.y = (char.ytile*game.tileH)+game.tileH/2;
char.width = char.clip._width/2;
char.height = char.clip._height/2;
char.clip._x = char.x;
char.clip._y = char.y;
}
buildMap(myMap);
Want als je nu een groot spel wilt hebben en je zit met over de 100 tiles, dan heb je dus 400 regels .