In order to add a completely new gameplay mechanic to this project, we will introduce a new powerup object that will give the player temporary superpowers.
As a first step to getting the powerup working, we’ll make it disappear when the player hits it and set up a new boolean variable to track that the player got it.
The powerup will only come into play in a very particular circumstance: when the player has a powerup AND they collide with an enemy - so we’ll first test for that very specific condition.
With the condition for the powerup set up perfectly, we are now ready to program the actual powerup ability: when the player collides with an enemy with the powerup, the enemy should go flying!
It wouldn’t be fair to the enemies if the powerup lasted forever - so we’ll program a countdown timer that starts when the player collects the powerup, removing the powerup ability when the timer is finished.
To make this game a lot more playable, it should be clear when the player does or does not have the powerup, so we’ll program a visual indicator to display this to the user.