Game Development Reference
In-Depth Information
private function updateScoreBoard():void {
dispatchEvent(new CustomEventScoreBoardUpdate(CustomEventScoreBoardUpdate.
UPDATE_TEXT, Main.SCORE_BOARD_SCORE, String(score)));
dispatchEvent(new CustomEventScoreBoardUpdate(CustomEventScoreBoardUpdate.
UPDATE_TEXT,Main.SCORE_BOARD_AMMO,String(ammo)));
dispatchEvent(new CustomEventScoreBoardUpdate(CustomEventScoreBoardUpdate.
UPDATE_TEXT,Main.SCORE_BOARD_TANKS,String(lives)));
dispatchEvent(new CustomEventScoreBoardUpdate(CustomEventScoreBoardUpdate.
UPDATE_TEXT,Main.SCORE_BOARD_HEALTH,String(player.healthPoints)
+ "/" + String(playerStartHealthpoints)));
}
override public function runGame():void {
checkInvincible();
if (playerStarted) {
checkInput();
}
update();
checkCollisions();
render();
checkforEndLevel();
checkforEndGame();
updateScoreBoard();
}
private function checkInvincible():void {
if (playerInvincibleCountDown && playerInvincible) {
playerInvincibleCount++
if (playerInvincibleCount > playerInvincibleWait) {
playerInvincible = false;
playerInvincibleCountDown = false;
playerInvincibleCount = 0;
player.visible = true;
}
}
}
Adding the CheckInput function
The checkInput function requires us to uncomment all of the lines for playing sounds and firing
missiles. See the following bold code:
private function checkInput():void {
var playSound:Boolean = false;
var lastDirection:int = player.currentDirection;
if (keyPressList[38] && player.inTunnel==false) {
Search WWH ::




Custom Search