Game Development Reference
It's also possible to add muliple costumes that are chosen randomly on each
loop. We can add a switch costume to () block inside the if () statement, ater the
x posiion in the x posiion < () block is reset. This funcionality is taken from the
parallax scrolling objects.
The following screenshot shows the final script:
Adding scores and power-ups
To prepare for the upcoming boss batle (next project), it's a nice touch to power up the
player character. A power-up system also ofers a beter reason for shooing enemies apart
from the need for survival.
We will assign a score value to each enemy type. The player can increase the score by
shooing the enemy of the corresponding type. When the player has defeated enough
enemies, the spear will be powered up in some way.
1. 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.