Having a brain freeze today. I’ve got a function which builds a tile map, nothing special.
Here’s some of the code:
function build(map) {
_root.createEmptyMovieClip("game", 10);
_root.game.attachMovie("chopper","chopper",5000);
_root.game.chopper._x = 200
_root.game.chopper._y = 100
_root.game.chopper.onEnterFrame = handleFrame;
game._x = startX;
game._y = startY;
for (i=0; i < mapH; i++) {
for (j=0; j < mapW; j++) {
_root.game.attachMovie("tiles", "tile_"+i+"_"+j, ++d);
_root.game["tile_"+i+"_"+j]._x = (tileW/2)*(j-i);
_root.game["tile_"+i+"_"+j]._y = (tileH/2)*(j+i);
_root.game["tile_"+i+"_"+j].gotoAndStop(map*[j]+1);
}
}
game.chopper.swapDepths(++d);
}
That’s nice and simple. I’ve a frame handler for the chopper mc, which handles which direction the chopper is moving in, and calls the following function:
function moveMap(x, y) {
speed = 3;
movx = x/speed
movy = y/speed
game._x -= movx;
game._y -= movy;
game.chopper._x += movx;
game.chopper._y += movy;
}
Again nice and simple, I just can’t seem to get my head around how I would work out which tile the chopperis currently over.
Any pointers would be much appreciated !
I’m feeling pretty dumb over this one