Game Development Reference
In-Depth Information
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));
}
}
Here is a list of changes we made:
We uncommented this line for the variable that will signal whether or not to play the tank
moving sound: var playSound:Boolean = false;
There should be eight places inside the if:else clause to uncommented the line
playSound = true; .
At the bottom of the function, you should uncomment the line that calls the
firePlayerMissile
pressed: if (ammo >0)
when
the
space
bar
is
firePlayerMissile(); .
We uncomment the line for playing the SOUND_PLAYER_MOVE sound if playSound was set to
true in step 2:
if (lastDir == MOVE_STOP && playSound) {
dispatchEvent(new CustomEventSound(CustomEventSound.PLAY_SOUND, É
Main.SOUND_PLAYER_MOVE, false, 1, 0));
}
Improving the update function
We need to add in code to update the invincibility for the player, the game missiles, and the
explosions. Notice that when a missile hits a wall, it will create a small explosion and then is
passed to the dispose function to be deleted. The same goes for explosions that have run their
Search WWH ::




Custom Search