Game Development Reference
In-Depth Information
if (keyPressList[39] && player.inTunnel==false) {
if (checkTile(MOVE_RIGHT, player )) {
if (player.currentDirection == MOVE_RIGHT || player.currentDirection
== MOVE_LEFT || player.currentDirection == MOVE_STOP) {
switchMovement(MOVE_RIGHT, player );
//playSound = true;
}else if (checkCenterTile( player)) {
switchMovement(MOVE_RIGHT, player );
//playSound = true;
}
}else {
//trace("can't move right");
}
}
if (keyPressList[37] && player.inTunnel==false) {
if (checkTile(MOVE_LEFT,player )) {
if (player.currentDirection == MOVE_LEFT || player.currentDirection
== MOVE_RIGHT || player.currentDirection == MOVE_STOP) {
switchMovement(MOVE_LEFT, player );
//playSound = true;
}else if (checkCenterTile(player)) {
switchMovement(MOVE_LEFT, player );
//playSound = true;
}
}else {
//trace("can't move left");
}
}
if (keyPressList[32]&& player.inTunnel==false) {
//if (ammo >0) firePlayerMissile();
}
//if (lastDirection == MOVE_STOP && playSound) {
//dispatchEvent(new CustomEventSound(CustomEventSound.PLAY_SOUND,
Main.SOUND_PLAYER_MOVE, false, 1, 0));
//}
}
There are many methods to do tile-based collision checking. We will implement a set of logic here
that is very specific to this game type. It would not (for instance) be suitable for a free-moving
overhead driving game. Luckily, we cover that topic in Chapter 10.
Search WWH ::




Custom Search