SCRATCH GOLD II
SCRATCH GOLD I
2 of 3

2.06 Dodging balls

Your character can move and jump now, so it’s time to add some balls that the character has to avoid.

Create a new ball sprite. You can choose any type of ball you like.

screenshot

Resize the ball sprite so that the character can jump over it. Try making the character jump over the ball to test whether the ball is the right size.

screenshot

Add this code to your ball sprite:

ball sprite

This code creates a new clone of the ball sprite every three seconds. Each new clone moves along the top platform and then drops.

Click the flag to test the game.

screenshot

Add more code to your ball sprite so that clones of it move across all three platforms.

screenshot

Now add some code blocks to broadcast (send) a message if your character gets hit by a ball!

Add this code to your ball sprite:

ball sprite

Finally, add code blocks to your character sprite to make it move back to its starting position when it receives the hit message:

pico walking sprite

Test out your code. Check whether the character moves back to the start after touching a ball.

×
×

Cart