Let’s add a timer, so that the player has to score as many goals as they can in 30 seconds.
Make a new variable
called timer
.
Click on your stage, and add this code to set the
to 30 at the start of the game.timer
Next, you’ll need to add a repeat until
block, so that the timer can run until it gets to 0.
Reduce your timer by 1 every second until it reaches 0.
Once the timer has reached 0, you should play the 'whistle' sound
and then stop the game.
Click the green flag to test your code. Your timer should start at 30, and end at 0.
You can change your timer to start at 10 if you don’t want to wait for 30 seconds!
You only have the chance to score 1 goal! To have more than 1 chance, add a forever
block around your football code. You can also add a wait
block between attempts.