Game state and progression
The main thing our game has been lacking so far is an end. The enemies never stop flying at the player and the player never dies because the only penalty for dying is a score penalty. To have a high score, we need an end where we can freeze the score and say the player has earned it. To do this, we need to add in a way to end the game when the player dies. In the next chapter we'll look at implementing a proper menu system, but for now we'll focus on adjusting our game so that it ends and displays a score to the player.
To get started we need to change our game so that it ends at some point. We'll do this by damaging the player when the enemy collides with the player ship. This has the added benefit of giving us a flag that indicates if the player is alive and therefore if the game is running or finished. Thankfully we already have this functionality in the Ship base class that the Player inherits from, so we can go ahead and use that. We also need to decide how...