انتقل للمحتوى
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

If… then

Section 6: Conditions and sensingLesson 6.1 · ⏱ 7 min

The if block asks a question. If the answer is “yes” it runs the blocks inside it, and if it is “no” it skips them. The question goes in the hexagon shape, and comes from the Sensing blocks (light blue).

Blocks: when 🚩 clicked, forever
🖥️ What happens on the stage?
Robo walks, and when he touches the edge he says Ouch! and turns to come back.
📌 Note
We put if inside forever so it asks the question all the time, not just once.

📌 Another example: Robo grows at every edge

Inside forever we ask at every step: is Robo touching the edge? If yes, he turns back and grows by 15.

Blocks: when 🚩 clicked, go to x: (0) y: (0), point in direction (90), set size to (60) %, forever
The start of the trip
The start of the trip
He grew at every edge
He grew at every edge
✍️ Practise
Make Robo switch his costume every time he touches the edge.
✍️ Practise here in the lessonor open the lab in a new page ↗

🎯 Challenge yourself

Easy

Every time Robo touches the edge he goes back to the middle and says “Again! 🔁”.

👀 Show the solution
Blocks: when 🚩 clicked, go to x: (0) y: (0), point in direction (90), forever
The result on the stage
The result on the stage
Medium

Use if … else: Robo says “Right ➡️” if x is greater than 0, else he says “⬅️ Left”. Make him glide from left to right.

👀 Show the solution
Blocks: when 🚩 clicked, go to x: (-150) y: (0), glide (2) secs to x: (150) y: (0)
Blocks: when 🚩 clicked, forever
He reached the right
He reached the right
Hard

“You can't catch me” game: if the mouse touches Robo, he jumps to a random place.

👀 Show the solution
Blocks: when 🚩 clicked, go to x: (0) y: (0), forever
Robo ran away from the mouse
Robo ran away from the mouse
Finished the lesson? Mark it so your progress counts.