The goal of this game is to collect power from the lightning strikes. Our game scene will have a Knight dressed in his metal armour, this protective suit will help him collect electricity to charge up the ball sprite.
Of course the rain will reduce his electric charge by one.
Our player will control the knight by using the arrow keys.
Sprites
We need to use a number of sprites for this game. I’ve used Button 2 to be our rain drops, I used the shrink tool to make them the perfect size.
Knight Movement
The knight can move only from left to right, to achieve this we will use the keyboard hat blocks and move the knight only along the X axis.
Power Score
We will create a variable called ‘Power’ that we will use to keep track of how much power we have collected.
On our Knight Sprite we will add a check to see if we are touching the lightning and change our Power by one if we are touching:
We wait for one second after each time we are touching the lightning before checking again. This delay will mean that our score only goes up by a maximum of 1 per second.
Lightning Our lighting will fall from the sky quickly. We first want our player to be able to see where it is going to form, then we have it fall to the bottom of the screen quickly before being removed from the scene.
We are going to use sprite clones to make the lightning work nicely. When the game starts we are going to use a forever loop that creates a clone every second:
Now when the lightning starts as a clone, we want to make it move from top to bottom.
Clouds
Our clouds will move randomly across the screen only from left to right.
We set the X between -220 and 220 so that it’s not quite off the screen. Remember the screen size is -240 to 240. The clouds can move randomly between 1 and 5 seconds.
Rain
Our rain sprite is also going to use clones. We are going to use very similar code to our cloud sprite, we only want it to rain randomly.
Now when the rain sprite is created it needs to start directly on the cloud. Then we need to make it fall to the bottom of the screen.
If it touches the Knight on the way down, we need to remove some power. If it touches the edge of the screen the clone should be deleted.
Power Orb
The power orb will change colours depending on how much power the Knight adds to it.
Extra
Add more If statements to change the Orb colour as more power is added to it. There are 5 costume colours to choose from.