Programming for Children
Primary 6 · Science and Elementary Technology
Programming for Children
Lesson 6 of 6
35 min
Let's begin
Ishimwe and Uwase have an idea for a game called Catch the Mangoes. A basket moves along the bottom of the stage. Mangoes fall from the top of the tree, and every mango you catch earns a point. But watch out: falling stones take a point away! You have 30 seconds. Today you will plan and build this game.
| Game part | In Catch the Mangoes |
|---|---|
| Player sprite | The basket, moved with the arrow keys |
| Target | A mango that falls from the top |
| Obstacle | A stone that also falls |
| Rules | Catch a mango: +1. Touch a stone: −1. The game ends when the time reaches 0. |
| Variables | score and time |
The basket must keep checking the arrow keys all through the game, so the checks go inside a forever loop. The picture below shows the same idea: forever, if the right arrow key is pressed, move 10 steps.

when green flag clicked
go to x: (0) y: (-150)
forever
if <key [right arrow] pressed?> then
change x by (10)
if <key [left arrow] pressed?> then
change x by (-10)
when green flag clicked
go to x: (pick random (-200) to (200)) y: (170)
forever
change y by (-5)
if <touching [basket]?> then
change [score] by (1)
go to x: (pick random (-200) to (200)) y: (170)
if <(y position) < (-170)> then
go to x: (pick random (-200) to (200)) y: (170)
The stone sprite uses the same script, but with change [score] by (-1). For a harder game, make the stone stop everything with stop [all].
On the Stage: set [score] to (0), set [time] to (30), then repeat until (time) = (0) [wait (1) seconds, change [time] by (-1)], and finally stop [all], just like the timer in Ghostbusters.
An if … then block (Control) runs the blocks inside it only when its condition is true. The six-sided condition blocks, such as touching [basket]? and key [space] pressed?, come from Sensing. The Motion block if on edge, bounce works in the same way: IF the sprite touches the edge, it turns back, like the bouncing asteroid in Lost in space.
Ask a friend to be your tester. Is it too easy? Make things fall faster (change y by −8) or give less time. Does the score go up twice for one mango? Make sure the mango jumps back to the top as soon as it is caught.
Tip
Forever + if + sensing = a game. Almost every game is a loop that keeps asking "IF this happened, THEN do that".
Answers
What you learned today
Sources and credits
The exercises (Try it yourself and the practice questions) are written by Ganzaa.
This lesson adapts CC BY-SA material and is shared under CC BY-SA 4.0.
Quick check
Match each game part to what it is in Catch the Mangoes.
Tap one on the left, then its partner on the right.