انتقل للمحتوى
Robo EgyptRobo Egypt
☰ Course contents
Robo Block: home
0. Lab tour1
1. Getting started5
2. Motion5
3. Looks and sound5
4. Events4
5. Loops5
6. Conditions and sensing4
7. Variables and randomness4
8. Project: the “Catch Robo” game3
9. Messages: characters talk to each other4
10. Clones: one character, many copies4
11. My Blocks: make a new block3
12. Operators and time4
13. The pro project: a jumping game4

The timer

Section 12: Operators and timeLesson 12.2 · ⏱ 6 min

timer is a clock that counts the seconds since the program started, and reset timer puts it back to zero. wait until waits until the condition is true.

Blocks: when 🚩 clicked, go to x: (0) y: (-40), reset timer, say (Wait 3 seconds…), wait until <(timer > 3)>, say (3 seconds have passed!) for (3) seconds
Robo waits
Robo waits
After 3 seconds on the timer
After 3 seconds on the timer

📌 Another example: a reaction-time game

Robo resets the timer, then waits for space. When you press it he says how many seconds have passed: that's your reaction time.

Blocks: when 🚩 clicked, go to x: (0) y: (-40), say (Press space now!), reset timer, wait until <(key space pressed?)>, say (join Your time:  timer)
Robo waits
Robo waits
We pressed space
We pressed space
✍️ Practise
Make Robo say “Faster!” if 3 seconds pass and you haven't pressed space.
✍️ Practise here in the lessonor open the lab in a new page ↗

🎯 Challenge yourself

Easy

Robo says “One second”, then “Two seconds”, then “Three seconds ⏱” at the right time, with wait until timer > …

👀 Show the solution
Blocks: when 🚩 clicked, reset timer, wait until <(timer > 1)>, say (One second), wait until <(timer > 2)>, say (Two seconds), wait until <(timer > 3)>, say (Three seconds ⏱)
The result on the stage
The result on the stage
Medium

Robo spins without stopping, and a second script stops everything after 3 seconds.

👀 Show the solution
Blocks: when 🚩 clicked, go to x: (0) y: (0), forever
Blocks: when 🚩 clicked, reset timer, wait until <(timer > 3)>, say (Time's up!) for (1) seconds, stop all
Stopped after 3 seconds
Stopped after 3 seconds
Hard

The “exactly 5 seconds” game: if you press space with the timer between 4.5 and 5.5 he says “Well done! 🎯”, else he says how much time passed. (and)

👀 Show the solution
Blocks: when 🚩 clicked, reset timer, say (Press space after exactly 5 seconds), wait until <(key space pressed?)>, if <(<timer > 4.5> and <timer < 5.5>)> then
We pressed it in time
We pressed it in time
Finished the lesson? Mark it so your progress counts.