1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
| // tableau contenant les personnages
tblPersos = ["wolverine", "superman", "spiderman", "batman", "hulk"];
// carte en 2 dimensions de 64 cases praticables
myMap = [
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
[1, 0, 0, 0, 0, 0, 0, 0, 0, 1],
[1, 0, 0, 0, 0, 0, 0, 0, 0, 1],
[1, 0, 0, 0, 0, 0, 0, 0, 0, 1],
[1, 0, 0, 0, 0, 0, 0, 0, 0, 1],
[1, 0, 0, 0, 0, 0, 0, 0, 0, 1],
[1, 0, 0, 0, 0, 0, 0, 0, 0, 1],
[1, 0, 0, 0, 0, 0, 0, 0, 0, 1],
[1, 0, 0, 0, 0, 0, 0, 0, 0, 1],
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1]];
// déclaration des équipes
equipe = function(){}
equipe.prototype.origine = 150;
equipe1 = new equipe( );
equipe1.color = "rouge";
// declare carte object that holds info
carte = {tileW:100, tileH:100};
// cases praticables
carte.Tile0 = function () { };
carte.Tile0.prototype.walkable = true;
carte.Tile0.prototype.frame = 1;
// cases "mur"
carte.Tile1 = function () { };
carte.Tile1.prototype.walkable = false;
carte.Tile1.prototype.frame = 2;
function buildMap(map) {
// attach empty mc to hold all the tiles and char
_root.attachMovie("empty","tiles",++d);
// declare clip in the game object
carte.clip = _root.tiles;
// get map dimensions
var mapWidth = map[0].length;
var mapHeight = map.length;
// loop to place tiles on stage
for (var i = 0; i<mapHeight; ++i) {
for (var j = 0; j<mapWidth; ++j) {
// name of new tile
var name = "t_"+i+"_"+j;
// make new tile object in the game
carte[name] = new carte["Tile"+map[i][j]]();
// attach tile mc and place it
carte.clip.attachMovie("tile", name, i*100+j*2);
carte.clip[name]._x = (j*carte.tileW);
carte.clip[name]._y = (i*carte.tileH);
// send tile mc to correct frame
carte.clip[name].gotoAndStop(carte[name].frame);
}
}}
// insertion des persos
function buildPion (equipe, perso) {
var persoWidth = tblPersos.length;
for (var k = 0; k < persoWidth; ++k) {
this.attachMovie("pion_rouge", "p_"+k, 100+k);
this["p_"+k]._x = (k*carte.tileW+350);
this["p_"+k]._y = equipe.origine;
this["p_"+k].gotoAndStop(perso[k]);
}
}
buildMap(myMap);
buildPion (equipe1, tblPersos); |
Partager