Unit 2 · Lesson 4

Test, Customize, and Explain the Adventure

  • Finish the Adventure
  • 30 minutes
  • Advanced Scratch · Ages 8–11

Open Space Rescue 7. Play through the whole adventure, fix one thing at a time, then save your finished game.

Prerequisite: Scratch Meteor Challenge. Complete Meteor Challenge before adding rescue missions, custom blocks, and clones.

Your goal

Test pickups, deliveries, lives, the clock, missions and restart.

Do one step. Match the picture. Then move on.

  1. In Scratch

    Check the first mission

    Click the green flag. Check Goal 2, Lives 3, TimeLeft 45, Carrying 0 and TotalRescued 0. There should be one falling meteor.

    Actual Scratch Stage for Test and Customize Space Rescue after starting its lesson checkpoint.
    1. Click: Click the green flag for the final checks.
    Actual Scratch editor · step 1
  2. In Scratch

    Check all four directions

    Try every arrow and each screen edge. The ship should stay on screen. If one direction is wrong, check the two numbers in its move ship call.

    Actual Scratch close-up of Spaceship's Code area: if <key [right arrow] pressed?> then; call move ship (7) (0); if <key [left arrow] pressed?> then; call move ship (-7) (0); if <key [up arrow] pressed?> then; call move ship (0) (7); if <key [down arrow] pressed?> then; call move ship (0) (-7).
    1. Check: Check both inputs in all four movement calls.
    Actual Scratch editor · step 2
  3. In Scratch

    Check one pickup and delivery

    Touch an astronaut, then return to base. Carrying should go 0 → 1 → 0. Each rescue counter should increase only once for that passenger.

    Actual Scratch close-up of BaseStation's Code area: if <<GameState = playing> and <<Carrying = 1> and <touching [Spaceship]?>>> then; set [Carrying] to (0); change [RescuedMission] by (1); change [TotalRescued] by (1); if <RescuedMission = Goal> then / else; set [GameState] to (between); broadcast [rescue delivered].
    1. Check: Check that one delivery changes the counters once.
    Actual Scratch editor · step 3
  4. In Scratch

    Check hits and protection

    Touch a meteor. Lose one life, then get about one second of protection. After three separate hits, Out of lives should appear. Restart must still work.

    Actual Scratch close-up of Meteor's Code area: set [HurtUntil] to (timer + 1); change [Lives] by (-1).
    1. Check: Check the one-second HurtUntil protection.
    Actual Scratch editor · step 4
  5. In Scratch

    Check the clock

    Restart and let the clock expire without completing the goal. Check Time is up and TimeLeft 0. Restart again: the clock returns to 45.

    Actual Scratch close-up of Stage's Code area: set [GameState] to (resetting); set [GameState] to (playing); repeat until <not <GameState = playing>>; if <GameState = playing> then; if <TimeLeft = 0> then; set [GameState] to (lost); broadcast [end mission].
    1. Check: Check the TimeLeft zero ending.
    Actual Scratch editor · step 5
  6. In Scratch

    Check all three missions

    Complete goals 2, 3 and 4. Check meteor counts 1, 2 and 3. Click Next Mission only on Mission complete. After mission 3, Adventure complete appears.

    Actual Scratch close-up of Stage's Code area: when I receive [mission clear]; if <GameState = between> then; if <Mission = 3> then / else; set [GameState] to (won); switch backdrop to [Adventure complete]; switch backdrop to [Mission complete]; broadcast [end mission] and wait.
    1. Check: Check the success choice after each mission.
    Actual Scratch editor · step 6
  7. In Scratch

    Check the final log

    The final log should have three rows and TotalRescued should be 9. Start a new game: both the log and rescue total should clear.

    Actual Scratch Stage for Keep a Mission Log with Lists after starting its lesson checkpoint.
    1. Check: Watch TotalRescued while completing the three missions.
    2. Click: Restart to clear the total and log.
    Actual Scratch editor · step 7
  8. In Scratch

    Try repeated restarts

    Restart several times during play, between missions and after losing. Old meteors must disappear; the new first mission should still have only one meteor.

    Actual Scratch close-up of Meteor's Code area: when I receive [reset world]; hide; stop [other scripts in sprite]; delete this clone.
    1. Check: Check that resets delete old meteor clones.
    Actual Scratch editor · step 8
  9. Select Meteor

    Try one small change

    Save a working copy first. Change Mission + 3 to Mission + 2 in all three respawn calls in the clone stack. Meteors fall more slowly. Test every mission before keeping the change.

    Actual Scratch close-up of Meteor's Code area: call respawn (Mission + 3); if <GameState = playing> then; if <<GameState = playing> and <<touching [Spaceship]?> and <timer > HurtUntil>>> then; call respawn (Mission + 3); broadcast [player hit]; if <Lives = 0> then; set [GameState] to (lost); broadcast [end mission].
    1. Add: Change this speed to Mission + 2.
    2. Add: Change this respawn speed too.
    Actual Scratch editor · step 9
  10. In Scratch

    Save the finished adventure

    Choose File → Save to your computer. Name it Space Rescue Finished.sb3. Keep a separate copy of your last working version too.

    Actual Scratch open File menu including Load from your computer and Save to your computer.
    1. Click: Open File.
    2. Click: Choose Save to your computer.
    Actual Scratch editor · step 10
  11. In Scratch

    Share and ask for a play test

    If signed in, choose Share at the top of Scratch. Give a friend the project link. Ask them to test pickups, deliveries, lives, the clock and both buttons.

    Scratch Share button beside See Project Page at the top of the editor.
    1. Click: Choose Share only when your project is ready.
    Actual Scratch editor · step 11
Lost your place? Optional comparison files

Save your own work first. Loading an .sb3 replaces the project on screen.

Previous lesson comparison

Finished lesson 8 comparison

Optional: full block guide and finished game

Build with blocks · Lesson 8

See the blocks. Try the finished game.

Build these blocks in Scratch. This guide is read-only.

Your lesson’s block guide

Choose the matching sprite in Scratch, then build its stack from top to bottom.

Indented rows fit inside the block above. else marks the second slot of one if/else block.

My Blocks inputs pass values into one call. FallSpeed belongs to each meteor clone; MissionLog is a shared list for the current adventure.

StageStage: define prepare mission values
  1. My Blocksdefine prepare mission values
  2. Variablesset [Goal] to (Mission + 1)
  3. Variablesset [RescuedMission] to (0)
  4. Variablesset [Carrying] to (0)
  5. Variablesset [HurtUntil] to (0)
  6. Variablesset [TimeLeft] to (45)
  7. Variableshide list [MissionLog]
  8. Controlif <Mission = 1> then
  9. Looksswitch backdrop to [Mission 1]
  10. elseSecond slot of the same if/else block
    Controlif <Mission = 2> then
  11. Looksswitch backdrop to [Mission 2]
  12. elseSecond slot of the same if/else block
    Looksswitch backdrop to [Mission 3]
StageStage: when green flag clicked
  1. Eventswhen green flag clicked
  2. Eventsbroadcast [new game]
StageStage: when I receive [new game]
  1. Eventswhen I receive [new game]
  2. Controlstop [other scripts in sprite]
  3. Variablesset [GameState] to (resetting)
  4. Variablesset [Mission] to (1)
  5. Variablesset [TotalRescued] to (0)
  6. Variablesset [Lives] to (3)
  7. Sensingreset timer
  8. Variablesdelete all of [MissionLog]
  9. Eventsbroadcast [prepare mission]
StageStage: when I receive [prepare mission]
  1. Eventswhen I receive [prepare mission]
  2. Controlstop [other scripts in sprite]
  3. Variablesset [GameState] to (resetting)
  4. Eventsbroadcast [reset world] and wait
  5. My Blockscall prepare mission values
  6. Variablesset [GameState] to (playing)
  7. Eventsbroadcast [play mission]
  8. Controlrepeat until <not <GameState = playing>>
  9. Controlwait (1) seconds
  10. Controlif <GameState = playing> then
  11. Variableschange [TimeLeft] by (-1)
  12. Controlif <TimeLeft = 0> then
  13. Variablesset [GameState] to (lost)
  14. Eventsbroadcast [end mission]
StageStage: when I receive [mission clear]
  1. Eventswhen I receive [mission clear]
  2. Controlif <GameState = between> then
  3. Variablesadd [join [Mission ] [join [Mission] [join [: ] [join [RescuedMission] [ rescued]]]]] to [MissionLog]
  4. Controlif <Mission = 3> then
  5. Variablesset [GameState] to (won)
  6. Looksswitch backdrop to [Adventure complete]
  7. elseSecond slot of the same if/else block
    Looksswitch backdrop to [Mission complete]
  8. Eventsbroadcast [end mission] and wait
  9. Variablesshow list [MissionLog]
StageStage: when I receive [end mission]
  1. Eventswhen I receive [end mission]
  2. Controlif <GameState = lost> then
  3. Controlif <Lives = 0> then
  4. Looksswitch backdrop to [Out of lives]
  5. elseSecond slot of the same if/else block
    Looksswitch backdrop to [Time is up]
  6. Variablesshow list [MissionLog]
StageStage: when I receive [next mission]
  1. Eventswhen I receive [next mission]
  2. Controlif <GameState = between> then
  3. Variablesset [GameState] to (resetting)
  4. Variableschange [Mission] by (1)
  5. Eventsbroadcast [prepare mission]
SpaceshipSpaceship: define move ship (dx) (dy)
  1. My Blocksdefine move ship (dx) (dy)
  2. Motionchange x by (dx)
  3. Motionchange y by (dy)
  4. Controlif <x position > 210> then
  5. Motionset x to (210)
  6. Controlif <x position < -210> then
  7. Motionset x to (-210)
  8. Controlif <y position > 125> then
  9. Motionset y to (125)
  10. Controlif <y position < -155> then
  11. Motionset y to (-155)
SpaceshipSpaceship: when I receive [reset world]
  1. Eventswhen I receive [reset world]
  2. Controlstop [other scripts in sprite]
  3. Lookshide
  4. Lookssay []
  5. Looksclear graphic effects
  6. Motiongo to x: (0) y: (-130)
SpaceshipSpaceship: when I receive [play mission]
  1. Eventswhen I receive [play mission]
  2. Looksshow
  3. Controlforever
  4. Controlif <GameState = playing> then
  5. Controlif <key [right arrow] pressed?> then
  6. My Blockscall move ship (7) (0)
  7. Controlif <key [left arrow] pressed?> then
  8. My Blockscall move ship (-7) (0)
  9. Controlif <key [up arrow] pressed?> then
  10. My Blockscall move ship (0) (7)
  11. Controlif <key [down arrow] pressed?> then
  12. My Blockscall move ship (0) (-7)
  13. Controlif <Carrying = 1> then
  14. Lookssay [Passenger aboard!]
  15. elseSecond slot of the same if/else block
    Lookssay []
  16. Controlif <timer < HurtUntil> then
  17. Looksset [ghost] effect to (45)
  18. elseSecond slot of the same if/else block
    Looksclear graphic effects
SpaceshipSpaceship: when I receive [end mission]
  1. Eventswhen I receive [end mission]
  2. Controlstop [other scripts in sprite]
  3. Lookshide
  4. Lookssay []
  5. Looksclear graphic effects
SpaceshipSpaceship: when I receive [player hit]
  1. Eventswhen I receive [player hit]
  2. Soundstart sound [Hit]
AstronautAstronaut: when I receive [reset world]
  1. Eventswhen I receive [reset world]
  2. Controlstop [other scripts in sprite]
  3. Lookshide
  4. Lookssay []
  5. Motiongo to x: (pick random (-190) to (190)) y: (pick random (0) to (45))
AstronautAstronaut: when I receive [play mission]
  1. Eventswhen I receive [play mission]
  2. Looksshow
  3. Controlforever
  4. Controlif <<GameState = playing> and <<Carrying = 0> and <touching [Spaceship]?>>> then
  5. Variablesset [Carrying] to (1)
  6. Lookshide
  7. Soundstart sound [Rescue]
AstronautAstronaut: when I receive [rescue delivered]
  1. Eventswhen I receive [rescue delivered]
  2. Controlif <GameState = playing> then
  3. Motiongo to x: (pick random (-190) to (190)) y: (pick random (0) to (45))
  4. Looksshow
AstronautAstronaut: when I receive [end mission]
  1. Eventswhen I receive [end mission]
  2. Controlstop [other scripts in sprite]
  3. Lookshide
BaseStationBaseStation: when I receive [reset world]
  1. Eventswhen I receive [reset world]
  2. Controlstop [other scripts in sprite]
  3. Lookshide
  4. Motiongo to x: (0) y: (-140)
BaseStationBaseStation: when I receive [play mission]
  1. Eventswhen I receive [play mission]
  2. Looksshow
  3. Controlforever
  4. Controlif <<GameState = playing> and <<Carrying = 1> and <touching [Spaceship]?>>> then
  5. Variablesset [Carrying] to (0)
  6. Variableschange [RescuedMission] by (1)
  7. Variableschange [TotalRescued] by (1)
  8. Controlif <RescuedMission = Goal> then
  9. Variablesset [GameState] to (between)
  10. Eventsbroadcast [mission clear]
  11. elseSecond slot of the same if/else block
    Eventsbroadcast [rescue delivered]
  12. Soundstart sound [Rescue]
BaseStationBaseStation: when I receive [end mission]
  1. Eventswhen I receive [end mission]
  2. Controlstop [other scripts in sprite]
  3. Lookshide
MeteorMeteor: define respawn (speed)
  1. My Blocksdefine respawn (speed)
  2. Variablesset [FallSpeed · this sprite only] to (speed)
  3. Motiongo to x: (pick random (-205) to (205)) y: (180)
  4. Looksshow
MeteorMeteor: when I receive [reset world]
  1. Eventswhen I receive [reset world]
  2. Lookshide
  3. Controlstop [other scripts in sprite]
  4. Controldelete this clone
MeteorMeteor: when I receive [end mission]
  1. Eventswhen I receive [end mission]
  2. Lookshide
  3. Controlstop [other scripts in sprite]
  4. Controldelete this clone
MeteorMeteor: when I receive [play mission]
  1. Eventswhen I receive [play mission]
  2. Lookshide
  3. Controlrepeat (Mission)
  4. Controlcreate clone of [myself]
MeteorMeteor: when I start as a clone
  1. Controlwhen I start as a clone
  2. My Blockscall respawn (Mission + 3)
  3. Controlforever
  4. Controlif <GameState = playing> then
  5. Motionchange y by (0 - FallSpeed)
  6. Controlif <<GameState = playing> and <<touching [Spaceship]?> and <timer > HurtUntil>>> then
  7. Variablesset [HurtUntil] to (timer + 1)
  8. Variableschange [Lives] by (-1)
  9. My Blockscall respawn (Mission + 3)
  10. Eventsbroadcast [player hit]
  11. Controlif <Lives = 0> then
  12. Variablesset [GameState] to (lost)
  13. Eventsbroadcast [end mission]
  14. Controlif <<GameState = playing> and <y position < -175>> then
  15. My Blockscall respawn (Mission + 3)
Start / RestartStart / Restart: when green flag clicked
  1. Eventswhen green flag clicked
  2. Motiongo to x: (155) y: (150)
  3. Looksshow
Start / RestartStart / Restart: when this sprite clicked
  1. Eventswhen this sprite clicked
  2. Eventsbroadcast [new game]
Next MissionNext Mission: when green flag clicked
  1. Eventswhen green flag clicked
  2. Motiongo to x: (145) y: (-140)
  3. Lookshide
Next MissionNext Mission: when I receive [reset world]
  1. Eventswhen I receive [reset world]
  2. Controlstop [other scripts in sprite]
  3. Lookshide
Next MissionNext Mission: when I receive [end mission]
  1. Eventswhen I receive [end mission]
  2. Controlif <GameState = between> then
  3. Looksshow
  4. elseSecond slot of the same if/else block
    Lookshide
Next MissionNext Mission: when this sprite clicked
  1. Eventswhen this sprite clicked
  2. Controlif <GameState = between> then
  3. Eventsbroadcast [next mission]
Download lesson 8 checkpoint

Save your current Scratch project first. Then choose File → Load from your computer and select this .sb3 file.

Open the Scratch editor ↗

Opening the editor does not load the download automatically.

Finished game preview

This is the completed game, including features from later lessons. It does not run this lesson’s checkpoint.

Choose the green flag, then use all four arrow keys inside the Scratch player. Open your checkpoint in Scratch to test the blocks for this lesson.

Open the finished game in a new tab ↗
END OF LESSON

Ready for the next step?

Return here anytime to review.

Finished project

Space Rescue Adventure

Pilot your spaceship with all four arrow keys, pick up astronauts, and return them to the station. Complete three rescue missions while avoiding cloned meteors and managing your lives and mission timer.

Compare this working example with your own project. It opens in a new tab.

Play the finished Space Rescue Adventure
Comments

Lesson discussion

Ask a question or help a classmate. Mr. S can reply here.

Loading discussion…