ุงู†ุชู‚ู„ ู„ู„ู…ุญุชูˆู‰
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 last project: jump over the dog

Section 13: The pro project: a jumping gameLesson 13.3 ยท โฑ 15 min
๐ŸŽฏ Project goal
A dog runs towards Robo, and Robo jumps over it. Every time the dog gets past, the score goes up. And if they bump: โ€œYou lost!โ€.
๐Ÿ“Œ Note
Add the dog: click โž• Character under the stage and choose โ€œDogโ€. Each character has its own blocks: click the character first, then snap its blocks.

How does Robo know the dog touched him? With the question touching (Dog)? from the Sensing blocks. Open its little list and you will find the names of all the characters you added; choose the dog.

๐Ÿงฉ ๐Ÿค– Robo: Robo
Blocks: when ๐Ÿšฉ clicked, go to x: (-150) y: (-120), set (speed) to (0), set (score) to (0), forever
๐Ÿงฉ ๐Ÿถ Dog: the dog
Blocks: when ๐Ÿšฉ clicked, set size to (60) %, go to x: (230) y: (-125), forever
Robo jumps over the dog
Robo jumps over the dog
The score goes up with every good jump
The score goes up with every good jump
No jumping: the dog touched Robo, he said โ€œYou lost!โ€ and the game stopped
No jumping: the dog touched Robo, he said โ€œYou lost!โ€ and the game stopped
๐Ÿ–ฅ๏ธ What happens on the stage?
We played the game in Robo Block twice: once without jumping, so the dog touched Robo and he lost, and once with jumping, so the dog got past three times and the score became 3.
  1. Start with gravity and jumping (the last two lessons).
  2. Add the dog and make it run, then come back from the right.
  3. The question โ€œtouching (Dog)?โ€ inside if.
  4. Try it, and change the dog's speed until the game is fun.

๐Ÿ“Œ Another example: levels, the dog speeds up

A variable dogspeed starts at 6. Every 3 points (score mod 3 = 0) it goes up by 2 and Robo says โ€œNew level! ๐Ÿš€โ€. Here the dog is the one that asks: am I touching Robo? and sends โ€œyou lostโ€.

๐Ÿงฉ ๐Ÿค– Robo
Blocks: when ๐Ÿšฉ clicked, go to x: (-150) y: (-120), set (speed) to (0), set (score) to (0), forever
๐Ÿงฉ ๐Ÿค– Robo
Blocks: when I receive (you lost), say (You lost! ๐Ÿ˜ฟ) for (2) seconds, stop all
๐Ÿงฉ ๐Ÿถ Dog
Blocks: when ๐Ÿšฉ clicked, set size to (60) %, go to x: (230) y: (-125), set (dogspeed) to (6), forever
We played for 11 seconds
We played for 11 seconds
โœ๏ธ Practise
Make your own game: change the characters, the backdrop and the sounds.
โœ๏ธ Practise here in the lessonor open the lab in a new page โ†—

๐ŸŽฏ Challenge yourself

Easy

Add movement to the jump: switch the costume at every jump, and count the jumps in a variable jumps.

๐Ÿ‘€ Show the solution
๐Ÿงฉ ๐Ÿค– Robo
Blocks: when ๐Ÿšฉ clicked, go to x: (-150) y: (-120), set (speed) to (0), set (score) to (0), forever
๐Ÿงฉ ๐Ÿค– Robo
Blocks: when I receive (you lost), say (You lost! ๐Ÿ˜ฟ) for (2) seconds, stop all
๐Ÿงฉ ๐Ÿถ Dog
Blocks: when ๐Ÿšฉ clicked, set size to (60) %, go to x: (230) y: (-125), set (dogspeed) to (6), forever
The result on the stage
The result on the stage
Medium

A โ€œyou lostโ€ screen: when โ€œyou lostโ€ arrives the backdrop changes, Robo says how to play again, then the game stops.

๐Ÿ‘€ Show the solution
๐Ÿงฉ ๐Ÿค– Robo
Blocks: when ๐Ÿšฉ clicked, go to x: (-150) y: (-120), set (speed) to (0), set (score) to (0), forever
๐Ÿงฉ ๐Ÿค– Robo
Blocks: when I receive (you lost), switch backdrop to (Room), say (You lost! ๐Ÿ˜ฟ Click the flag to play again) for (2) seconds, stop all
๐Ÿงฉ ๐Ÿถ Dog
Blocks: when ๐Ÿšฉ clicked, set size to (60) %, go to x: (230) y: (-125), set (dogspeed) to (6), forever
The โ€œyou lostโ€ screen
The โ€œyou lostโ€ screen
Hard

Best score: a variable best. When you lose, if score is more than best we keep it in best, and Robo says โ€œBest score:โ€ and the number.

๐Ÿ‘€ Show the solution
๐Ÿงฉ ๐Ÿค– Robo
Blocks: when ๐Ÿšฉ clicked, go to x: (-150) y: (-120), set (speed) to (0), set (score) to (0), forever
๐Ÿงฉ ๐Ÿค– Robo
Blocks: when I receive (you lost), if <(score > best)> then, say (join Best score:  best), stop all
๐Ÿงฉ ๐Ÿถ Dog
Blocks: when ๐Ÿšฉ clicked, set size to (60) %, go to x: (230) y: (-125), set (dogspeed) to (6), forever
After losing: the best score
After losing: the best score
Finished the lesson? Mark it so your progress counts.