This chapter covers
- Recording the player’s points score
- Adding to the player’s score
- Subtracting from the player’s score
- Displaying the score on screen
- Checking whether the player has beaten the current high score
In the previous chapter, we added collision detection to our game and detected when our player’s bullet encountered any of our enemy objects. Next we will work through how we keep track of and change the player’s score.
Our Mega Blast game is based on Astro Smash for the Intellivision, and in that game, you increase your score by shooting various enemies and decrease your score if any of the enemies make it to the ground. This is another good reason it makes a good example game, as we get to cover both increasing and decreasing the player’s score.
10.1 Keeping track of the player’s score
Every good shoot-em-up needs a way to keep track of the player’s score, so we will need to allow our players to rack up points as they progress through the game’s levels. We could just use some bytes of RAM and add values to them to increase the score, but we need to think about how the score will be displayed on the screen. We only have so much time in our NMI routine (where we write all changes to the screen), so to cut down the amount of time required to calculate and display the digits of the score, we will use a special method to keep track of each of the digits of the score.