Scratch 20 · Observatory Rescue

Three connected observatory rooms contain collectible gears, a rover and a telescope.

Scratch lesson 20 of 20 · Expert capstone · About 75–100 minutes

Guide a small rover through a moonlit observatory, rescue three repair parts and bring the telescope back online. Your room data, checkpoints and win screen all share the same game engine.

What you’ll make Build a complete three-room game that reads level layouts from lists, redraws the current room after a checkpoint restart, and remains easy to extend and test.

Get ready

Open the Scratch editor (opens in a new tab) and start a new project.

  • Start a fresh project. Add or paint three small sprites named Rover, Part and Exit. Give Rover a compact costume, Part a bright gear or disc, and Exit a gate about 45 pixels wide. Centre each costume in its editor so the touching checks match the artwork.
  • Create and name four Stage backdrops exactly as follows. Use Entry Hall, Lens Lab and Star Deck for the rooms, and Telescope Restored for the ending. Keep the rooms open for movement. Draw a telescope and a clear success message on the ending backdrop.
  • Make two variables for all sprites named Room and Mode. Keep the Room monitor visible and hide the Mode monitor. Make four lists for all sprites named Room backdrops, Part X, Part Y and Parts found.
  • Show the first three list monitors and use their plus buttons to enter three rows in the same order. Room backdrops gets Entry Hall, Lens Lab, Star Deck. Part X gets −85, 115, 0. Part Y gets 70, −75, 80. Type negative numbers with the minus key. Hide those three data monitors after filling them and keep Parts found visible.
  • Create the messages Draw room and Hide part when you first need them. Build all the My Blocks definitions on Rover. For load room, use Make a Block and add one number or text input named room number. Drag the matching reporter from the definition into the set block.

To keep your project, choose File → Save to your computer in Scratch.

Read the room data. Place the repair parts. → Collect a part. Record progress as you travel. → Repair the telescope. Check the win and reset rules.
Project flow · Read the room data → Collect a part → Repair the telescope

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. Let the Stage read the room table

The three data lists work like columns in a table. The same row number selects a backdrop name and the position of its part. Build this short receiver on the Stage. It chooses the ending when Mode is won. During play, drag the orange list reporter into the backdrop slot so the code can select a room by name. The controller will only request room numbers in the table.

Block stack for Stage
when I receive [Draw room]
if <(Mode) = [won]> then
switch backdrop to [Telescope Restored]
else
switch backdrop to (item (Room) of [Room backdrops])
↳ End of block

2. Draw each part and remember pickups

Add these two scripts to Part. If the rover has already collected a room’s part, the room number is in Parts found and the gear stays hidden on a redraw. Otherwise, use the corresponding X and Y values to place it. The second script hides the part immediately after the rover collects it. Use the list’s contains block inside the green or block.

Block stack for Part
when I receive [Draw room]
if <<(Mode) = [won]> or <[Parts found] contains (Room)?>> then
hide
else
go to x: (item (Room) of [Part X]) y: (item (Room) of [Part Y])
show
↳ End of block
when I receive [Hide part]
hide

3. Set the exit at the east edge

Give Exit its own short receiver. The position is shared by all three rooms, so put the gate at the same coordinates every time. Add the gate after painting the rooms so it is easy to see against each backdrop. This sprite has one job. Rover will decide if the gate can open.

Block stack for Exit
when I receive [Draw room]
if <(Mode) = [won]> then
hide
else
go to x: (184) y: (0)
show
↳ End of block

4. Make one block that loads any room

On Rover, define load room with the input from setup. It updates Room, moves the rover to the entrance and clears any old speech bubble. Use broadcast and wait so the Stage, Part and Exit finish drawing before the rover can move again. Every receiver is finite. The same block will run at the start, when the player moves through a gate and when they restart from their current room.

Block stack for Rover
define load room (room number)
set [Room] to (room number)
go to x: (-175) y: (0)
say []
broadcast [Draw room] and wait
show

5. Read the arrow keys and bound movement

Make a My Block named read arrows with no inputs. The four separate checks let the player move diagonally. The checks at the end clamp the rover’s centre to a rectangle inside the stage. Those checks run after the moves, so an arrow key held against an edge cannot push the rover any farther. A small costume leaves the rover fully visible at these limits.

Block stack for Rover
define read arrows
if <key [right arrow] pressed?> then
change x by (5)
↳ End of block
if <key [left arrow] pressed?> then
change x by (-5)
↳ End of block
if <key [up arrow] pressed?> then
change y by (5)
↳ End of block
if <key [down arrow] pressed?> then
change y by (-5)
↳ End of block
if <(x position) > (190)> then
set x to (190)
↳ End of block
if <(x position) < (-190)> then
set x to (-190)
↳ End of block
if <(y position) > (135)> then
set y to (135)
↳ End of block
if <(y position) < (-135)> then
set y to (-135)
↳ End of block

6. Collect each part once and check the gate

Add two more My Blocks on Rover. check part first asks whether the rover is touching Part and whether this room’s number is still missing from the list. Add the room before hiding Part so a later check cannot collect it twice. try gate only does anything when the rover touches Exit. If the room’s part is missing, the gate gives a hint. Otherwise, compare Room with the length of Room backdrops. Load the next row, or change Mode to won and redraw once after the last room.

Block stack for Rover
define check part
if <<touching [Part]?> and <not <[Parts found] contains (Room)?>>> then
add (Room) to [Parts found]
say []
broadcast [Hide part] and wait
↳ End of block
define try gate
if <touching [Exit]?> then
if <[Parts found] contains (Room)?> then
if <(Room) < (length of [Room backdrops])> then
load room ((Room) + (1))
else
set [Mode] to [won]
hide
broadcast [Draw room] and wait
↳ End of block
else
say [Find this room’s part first!]
↳ End of block
↳ End of block

7. Run the game from one controller loop

On Rover, add the only green-flag stack in the project. The flag clears the pickup list and starts in room 1. The loop handles movement, pickup, R for the current-room checkpoint and Space for the gate. Waiting for each action key to be released makes one press count once even if held down. R keeps the pickup list, so a part already collected stays collected. The game loop finishes after the Stage shows the win screen.

Block stack for Rover
when green flag clicked
delete all of [Parts found]
set [Mode] to [playing]
load room (1)
repeat until <(Mode) = [won]>
read arrows
check part
if <key [r] pressed?> then
load room (Room)
wait until <not <key [r] pressed?>>
↳ End of block
if <key [space] pressed?> then
try gate
wait until <not <key [space] pressed?>>
↳ End of block
wait (0.03) seconds
↳ End of block

Test your project

  1. Click the green flag. The Entry Hall appears, Room shows 1 and Parts found is empty. Walk against each stage edge and check that Rover stays visible.
  2. Visit the gate first. Press Space beside it and check that Rover asks for the missing part. Hold Space while away from the gate and check that no room change occurs.
  3. Touch the gear. Check that Parts found contains exactly one 1. Press R and check that Rover returns to the same room’s entrance, the gate is still usable and the part remains hidden.
  4. Collect all three parts in order and press Space at the last gate. Parts found should contain 1, 2 and 3 exactly once, the sprites should disappear and the Telescope Restored backdrop should appear.
  5. Click the green flag again after winning. The first room, its part and an empty pickup list should return.

If something goes wrong

The room backdrop or part is wrong.
Check that all three data lists have exactly three entries and that corresponding entries sit on the same row. Check the spelling and spacing of each backdrop name.
The rover freezes after walking through a gate.
Release Space. If it still freezes, check that every Draw room receiver ends promptly. Keep the game loop on Rover’s green-flag script.
A part comes back after using the checkpoint.
Check the Part sprite’s Draw room test and make sure Parts found is shared by all sprites. Clear that list only when the green flag is clicked.

Make it your own

  • Add a fourth room by adding a new backdrop and one row to each of the three data lists. Test all four gates and check that the final room now decides the win.
  • Add a fifth list named Gate Y. Fill one row per room and read it for Exit’s y position. Test that the new locations are reachable and separated from the parts.

What you’ve learned You used data to describe rooms, a single controller to decide when the game changes state, and small receivers to draw the result. That design lets you add new levels without copying the main loop.