Coding TIME LIMIT : Step Up Your Scratch Game
I will show you how to create a time limit, which is often used when creating games with Scratch.
Step1 Make a variable “TIME”
Press the “Make a Variable”,
then name the variable “TIME” ( whatever ).
Be sure to select “For all sprites”
Step2 Set the initial TIME
This step you will set the initial “TIME” in seconds.
If you want to set 60 sec, set TIME to 60 .
You can write the code wherever,
but in general, write it on Stage or main sprite (Sprite1) .
In this post, I write the code on Sprite1 (Cat).
Finally, place the code below “when green flag clicked” code.
Step3 Decrease the TIME by 1 second until it reaches 0
I’d like to decrease the TIME by 1 for each second.
Repeat as follows 60 times (until the TIME reaches 0)
wait 1 sec. → change TIME by -1
Here’s the code.
Step4 Closing logic
This is the last step.
I write the logic when the TIME reaches 0.
You write “stop all” at the bottom.
What you put in front of it is up to you depending on the program.
Cat says “Time is up!”
Change the backdrop.
…
Whatever
Entire Code
Here’s the entire code.