Game Development Reference
In-Depth Information
ship.deltaY = dy;
else
ship.deltaY = -dy;
}
}
/**
* Move the ship. If it is currently in hyper space, advance the
* count down.
*/
if (ship.active) {
ship.advance(width, height);
ship.render(width, height);
if (hyperCounter > 0)
hyperCounter--;
// Update the thruster sprites to match the ship sprite.
fwdThruster.x = ship.x;
fwdThruster.y = ship.y;
fwdThruster.angle = ship.angle;
fwdThruster.render(width, height);
revThruster.x = ship.x;
revThruster.y = ship.y;
revThruster.angle = ship.angle;
revThruster.render(width, height);
}
/**
* Ship is exploding, advance the countdown or create a new ship if it
* is done exploding. The new ship is added as though it were in
* hyper space. This gives the player time to move the ship if it is
* in imminent danger. If that was the last ship, end the game.
*/
else {
if (--shipCounter <= 0) {
if (shipsLeft > 0) {
initShip();
hyperCounter = Constants.HYPER_COUNT;
} else {
endGame();
}
}
}
}
Getting Scores
Scoring is the final step in the life cycle of Asteroids and is usually an optional step. In this step, a check
is performed too see if the game is over and, if so, get a final score and do something with it (such as
Search WWH ::




Custom Search