Adding scores and power-ups
To prepare for the upcoming boss battle (next project), it's a nice touch to power up the player character. A power-up system also offers a better reason for shooting enemies apart from the need for survival.
Engage thrusters
We will assign a score value to each enemy type. The player can increase the score by shooting the enemy of the corresponding type. When the player has defeated enough enemies, the spear will be powered up in some way.
We have three different enemy types, so we will first create the following three new variables to hold the scores. These variables are available for all sprites.
scoreRed
scoreBlue
scoreYellow
Click on the checkboxes in front of the new variables to make them visible on the stage. This way we can keep track of our scores.
At the start of the game, we set the values of these variables to
0
as shown in the following screenshot. The best place to do this is inside the stage object.Next, we will add a point to the correct variable...