Scratch lesson 9 of 10 · Intermediate · About 45–55 minutes
Guide a rover through a meadow and a cave. Use broadcasts to set up each level, protect three lives and give your game a proper ending.
What you’ll make Build a two-level rover game where the green flag resets everything, touching a barrier costs one life and two gates unlock the winning screen.
Get ready
Open the Scratch editor (opens in a new tab) and start a new project.
- Start a new Scratch project. Create three sprites called Rover, Gate and Barrier. Paint or choose a small character for Rover. Paint Gate as a bright square and Barrier as a narrow upright rectangle about 25 pixels wide and 180 pixels tall. Centre each drawing over the crosshair in the Costumes editor.
- On the Stage, make or choose four backdrops and name them Meadow, Cave, You win and Try again. Use different colours for Meadow and Cave so the change of scene is obvious.
- In Variables, make Level, Lives and Won for all sprites. Leave the Level and Lives monitors ticked and untick Won. You'll create the broadcast messages from the Events dropdowns as you build.
To keep your project, choose File → Save to your computer in Scratch.

Build it in Scratch
Choose the sprite named above each stack. The colours help you find the block categories. Indented rows sit inside the block above. Follow the end marker to see where each loop or condition closes.
1. Give the Stage a reset button
Select the Stage. These blocks reset the counters, ask every sprite to prepare the level and wait for those jobs to finish. Then the separate Play message starts the rover. The order matters because old positions can still be on screen when you restart.
when green flag clickedset [Level] to (1)set [Lives] to (3)set [Won] to (0)broadcast [Load round] and waitbroadcast [Play]2. Switch the backdrop for the current level
Still on the Stage, make this separate receiver for Load round. The Level variable decides which backdrop to show. Keep the scripts that receive Load round short and finite so the sender can carry on as soon as their jobs are done.
when I receive [Load round]if <(Level) = (1)> thenswitch backdrop to [Meadow]elseswitch backdrop to [Cave]3. Put the rover back at its starting point
On Rover, make a receiver for the same message. Scratch counts x left and right and y up and down from the centre. This puts Rover in the lower-left corner. Use the same numbers later in the life-loss branch so Rover starts each retry clear of the barrier.
when I receive [Load round]go to x: (-165) y: (-100)show4. Move the gate between levels
Select Gate and add this receiver. In Meadow the gate is high on the right. In Cave it sits lower. The message places the actual sprite, so the rover's touching check follows the gate to its new position.
when I receive [Load round]if <(Level) = (1)> thengo to x: (165) y: (100)elsego to x: (155) y: (-100)show5. Change the barrier's position
Select Barrier and give it its own receiver. The upright shape leaves a way around it on each backdrop. With the barrier near the bottom on level one, try steering above it. On level two, look for room below it.
when I receive [Load round]if <(Level) = (1)> thengo to x: (0) y: (-45)elsego to x: (40) y: (45)show6. Steer, lose lives and open gates
On Rover, build this Play script. Put all four checks for arrow keys first, then the touching checks inside the same repeat until loop. A barrier hit takes one life and immediately moves Rover away, so a single bump doesn't drain every life. Gate contact on level one loads level two before the loop moves Rover again. Gate contact on level two sets Won to 1.
when I receive [Play]repeat until <<(Lives) = (0)> or <(Won) = (1)>>if <key [right arrow] pressed?> thenchange x by (4)if <key [left arrow] pressed?> thenchange x by (-4)if <key [up arrow] pressed?> thenchange y by (4)if <key [down arrow] pressed?> thenchange y by (-4)if <touching [Barrier]?> thenchange [Lives] by (-1)go to x: (-165) y: (-100)elseif <touching [Gate]?> thenif <(Level) = (1)> thenset [Level] to (2)broadcast [Load round] and waitelseset [Won] to (1)broadcast [Game over]7. Show the right ending
Select the Stage. When Rover sends Game over, use Won to decide which ending to display. The movement loop has already ended, so the arrow keys won't move Rover on the end screen.
when I receive [Game over]if <(Won) = (1)> thenswitch backdrop to [You win]elseswitch backdrop to [Try again]8. Clear the board
Add this receiver to each of the three sprites. Their existing Load round scripts will show them the next time you click the green flag. Add a short message to each ending backdrop telling another player how to restart.
when I receive [Game over]hideTest your project
- Click the flag. Check that Meadow appears, Level shows 1, Lives shows 3 and Rover starts in the lower-left corner.
- Drive straight towards the barrier to test a bump. Check that Lives drops by exactly one and Rover jumps back to the start.
- Reach Gate on level one. Check that Cave appears, Level becomes 2 and your remaining Lives carry over. Reach the second gate to test You win.
- Restart and deliberately lose all three lives to test Try again. Click the flag once more and confirm all three sprites reappear.
If something goes wrong
- The game is stuck before the rover moves.
- Check that every Load round receiver can finish. A forever loop under that message keeps broadcast and wait waiting.
- The game loses several lives in a single bump.
- Confirm the jump to the start sits directly under change Lives by −1 and make sure Rover's starting spot is clear on both levels.
- The new scene appears, but the gate stays still.
- Check that the positions are in Gate's script and that both the Stage and Gate use the same Load round message.
Make it your own
- Change the second level's gate and barrier positions, then ask someone to find a safe route.
- Add a short sound when Level changes to 2. Put it in Gate's level-two branch so it plays once per successful transition.
What you’ve learned A broadcast sends one instruction to several sprites. Broadcast and wait gives each receiver time to finish setting up the level before the player moves.