11 Player collisions and lives
This chapter covers
- Handling the player’s ship colliding with enemies
- Animating the player’s death sequence
- Displaying the current player’s lives
- Handling the game-over message
In this chapter, we are going to cover handling the collision between the player and enemies, animating the player’s death sequence, and displaying the number of lives the player has remaining. Of course, once the player has run out of lives, we need to show Game Over on the screen, returning to our game intro screen so the player can view the high score and start a new game.
11.1 Player collisions
First, we need to detect if any of the enemy objects have hit the player’s ship. The best place to do this is in our existing enemy object loop, ...
Get Classic Game Programming on the NES now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.