Add danger and three lives
- Monsters and worlds
- 75 minutes
- Advanced Scratch · After Pixel Quest
Take one hit at a time and return to the menu after losing.
Recommended preparation: Scratch Pixel Quest. Complete Pixel Quest or bring equivalent Scratch platformer experience. Follow one short pictured action at a time.
Your goal
Make hazards and monsters cost one life, with brief protection after each hit.
The monsters can move. Now make touching a monster or spike cost one life. One touch must never take all three lives.
Do one step. Match the picture. Then move on.
Add Hazards
Upload the spike map
Upload meadow-hazards.png as a new sprite named Hazards. Set x 0, y 0 and Size 100. Keep the whole transparent canvas centered; it lines up with Platforms.
- Click: Point at Choose a Sprite
- Click: Click Upload Sprite
Actual Scratch editor · step 1 Select Stage’s thumbnail
Add the losing screen
Select Stage → Backdrops → Upload Backdrop. Add loss-screen.svg and name it Out of lives. Keep the earlier backdrops.
- Click: Open Backdrops
- Click: Point at Choose a Backdrop
- Click: Click Upload Backdrop
- Click: Rename this picture
Actual Scratch editor · step 2 Add Menu
Add a way back to the menu
Upload menu-button.svg as a new sprite named Menu. Set x 0, y -88 and Size 100. This button will appear after losing.
- Click: Point at Choose a Sprite
- Click: Click Upload Sprite
Actual Scratch editor · step 3 Select Stage’s thumbnail
Make shared Lives
Select Stage and make Lives. It is shared automatically. Untick its counter for now; the game will show it while playing.
- Click: Make each named variable
- Click: Untick the variable monitor boxes
Actual Scratch editor · step 4 Select Player
Make brief hit protection
On Player, make Invincible For this sprite only. Untick its counter. A value above 0 means another hit must wait.
- Click: Make each named variable
- Click: Untick the variable monitor boxes
Actual Scratch editor · step 5 Select Stage’s thumbnail
Start every new adventure with three lives
Add set Lives to 3 in Stage’s green-flag and new game stacks. Hide Lives on the menu; show Lives in load level. Keep the earlier Level resets.
- Add: Build stack 1 in this order
- Add: Build stack 2 in this order
- Add: Build stack 3 in this order
Actual Scratch editor · step 6 Select Player
Start without hit protection
In Player’s load level receiver, add set Invincible to 0 before show. Keep the other movement and animation resets.
- Add: Add or update the highlighted blocks
Actual Scratch editor · step 7 Select Player
Make the respawn receiver
Copy Player’s load level stack. Change its hat to when I receive respawn. In this copy, set Invincible to 30 before show. Keep the starting position and other resets.
- Add: Add or update the highlighted blocks
Actual Scratch editor · step 8 Select Player
Replace the old free-fall reset
In Player’s playing loop, remove only the old y position < -170 reset branch. In its place, add if Invincible > 0 → change Invincible by -1.
- Add: Add or update the highlighted blocks
Actual Scratch editor · step 9 Select Player
Send one shared hit message
After the protection countdown, add the pictured danger check. It asks for Invincible = 0 and a spike, Crawler, Bat or fall. Inside it, set GameState to hurt, then broadcast player hit.
- Add: Add or update the highlighted blocks
Actual Scratch editor · step 10 Select Stage’s thumbnail
Lose one life and respawn
On Stage, add when I receive player hit → if GameState = hurt → change Lives by -1. If Lives > 0, broadcast respawn and wait, then set GameState to playing.
- Add: Add or update the highlighted blocks
Actual Scratch editor · step 11 Select Stage’s thumbnail
Stop the adventure at zero lives
In the Lives check’s else branch, set GameState to lost, switch backdrop to Out of lives and broadcast game ended. Do not use stop all; Menu must still respond.
- Add: Build these blocks in this order
Actual Scratch editor · step 12 Select Stage’s thumbnail
Return to the title screen safely
On Stage, add when I receive show menu → set GameState menu → switch backdrop Title Screen → hide Level → hide Lives.
- Add: Add or update the highlighted blocks
Actual Scratch editor · step 13 Select Menu
Connect the Menu button
On Menu, build the two pictured stacks. Its green-flag loop shows Menu only when GameState = lost; otherwise hide. After show, go to front layer. Clicking Menu while lost broadcasts show menu.
- Add: Build this left stack
- Add: Build this right stack
Actual Scratch editor · step 14 Select Hazards
Give the spike map its receivers
Copy Platforms’ load level and show menu stacks onto Hazards. Keep x 0, y 0, switch costume to Level and show in the load receiver.
- Add: Build this left stack
- Add: Build this right stack
Actual Scratch editor · step 15 Select Player
Hide the world after losing
On Player, add when I receive game ended → hide. Copy this two-block receiver onto Platforms, Hazards, Crawler and Bat. Do not copy it onto the menu buttons.
- Add: Add or update the highlighted blocks
Actual Scratch editor · step 16 Select Player
Test a fair hit, the loss screen and save
Start with Lives 3. Touch a spike or monster: lose one life and return safely. At 0, the world hides and Menu returns to the title. Save as Monster Quest Lesson 06.
- Click: Run your test with the green flag
- Check: Check the game counters and messages
- Check: Run the movement or adventure test here
Actual Scratch editor · step 17
Optional: full block guide and lesson comparison
Save your own project first. Loading an .sb3 replaces the project on screen. This comparison shows the end of lesson 6.
Download lesson 6 comparison · Download all lesson comparisons
Choose the named sprite in Scratch and read its blocks from top to bottom. Indented rows fit inside the block above. Keep one copy of each existing stack.
StageOpen the title screen
- Eventswhen green flag clicked
- Variablesset [GameState] to (menu)
- Variablesset [Level] to (1)
- Variablesset [Lives] to (3)
- Looksswitch backdrop to [Title Screen]
- Variableshide variable [Level]
- Variableshide variable [Lives]
- Eventsbroadcast [show menu]
StageBegin a new game
- Eventswhen I receive [new game]
- Variablesset [GameState] to (loading)
- Variablesset [Level] to (1)
- Variablesset [Lives] to (3)
- Eventsbroadcast [load level] and wait
- Variablesset [GameState] to (playing)
StageLoad the selected level backdrop and counters
- Eventswhen I receive [load level]
- Looksswitch backdrop to [Meadow Steps]
- Variablesshow variable [Level]
- Variablesshow variable [Lives]
StageReturn safely to the title screen
- Eventswhen I receive [show menu]
- Variablesset [GameState] to (menu)
- Looksswitch backdrop to [Title Screen]
- Variableshide variable [Level]
- Variableshide variable [Lives]
StageLose one life and respawn or end
- Eventswhen I receive [player hit]
- Controlif <GameState = hurt> then
- Variableschange [Lives] by (-1)
- Controlif <Lives > 0> then
- Eventsbroadcast [respawn] and wait
- Variablesset [GameState] to (playing)
- elseSecond slot of the same if/else blockVariablesset [GameState] to (lost)
- Looksswitch backdrop to [Out of lives]
- Eventsbroadcast [game ended]
PlatformsLoad the level platforms costume
- Eventswhen I receive [load level]
- Motiongo to x: (0) y: (0)
- Looksswitch costume to [Level]
- Looksshow
PlatformsHide platforms on the menu
- Eventswhen I receive [show menu]
- Lookshide
PlatformsHide platforms on result screens
- Eventswhen I receive [game ended]
- Lookshide
PlayerPlace the explorer at the level start
- Eventswhen I receive [load level]
- Motiongo to x: (-210) y: (-126)
- Variablesset [XSpeed] to (0)
- Variablesset [YSpeed] to (0)
- Variablesset [Grounded] to (0)
- Variablesset [JumpHeld] to (0)
- Variablesset [StepY] to (-1)
- Variablesset [AnimTicks] to (0)
- Looksswitch costume to [Walk 1]
- Motionset rotation style [left-right]
- Motionpoint in direction (90)
- Variablesset [Invincible] to (0)
- Looksshow
PlayerHide the explorer on the title screen
- Eventswhen I receive [show menu]
- Lookshide
PlayerMove one horizontal pixel at a time
- My Blocksdefine move horizontally
- Controlrepeat (abs of (XSpeed))
- Motionchange x by ((XSpeed) / (abs of (XSpeed)))
- Controlif <touching [Platforms]?> then
- Motionchange x by ((0) - ((XSpeed) / (abs of (XSpeed))))
- Controlif <x position > 225> then
- Motionset x to (225)
- Controlif <x position < -225> then
- Motionset x to (-225)
PlayerLand on solid platforms a pixel at a time
- My Blocksdefine move vertically
- Variablesset [Grounded] to (0)
- Variablesset [StepY] to (-1)
- Controlif <YSpeed > 0> then
- Variablesset [StepY] to (1)
- Controlrepeat (abs of (round (YSpeed)))
- Motionchange y by (StepY)
- Controlif <touching [Platforms]?> then
- Motionchange y by ((0) - (StepY))
- Controlif <StepY < 0> then
- Variablesset [Grounded] to (1)
- Variablesset [YSpeed] to (0)
PlayerRead keys, move, jump and check the active adventure
- Eventswhen green flag clicked
- Controlforever
- Controlif <GameState = playing> then
- Variablesset [XSpeed] to (0)
- Controlif <key [left arrow] pressed?> then
- Variableschange [XSpeed] by (-4)
- Controlif <key [right arrow] pressed?> then
- Variableschange [XSpeed] by (4)
- My Blocksmove horizontally
- Controlif <key [space] pressed?> then
- Controlif <<JumpHeld = 0> and <Grounded = 1>> then
- Variablesset [YSpeed] to (11)
- Variablesset [JumpHeld] to (1)
- elseSecond slot of the same if/else blockVariablesset [JumpHeld] to (0)
- Variableschange [YSpeed] by (-0.7)
- Controlif <YSpeed < -12> then
- Variablesset [YSpeed] to (-12)
- My Blocksmove vertically
- Controlif <XSpeed < 0> then
- Motionpoint in direction (-90)
- Controlif <XSpeed > 0> then
- Motionpoint in direction (90)
- Controlif <Grounded = 0> then
- Looksswitch costume to [Walk 2]
- elseSecond slot of the same if/else blockControlif <XSpeed = 0> then
- Looksswitch costume to [Walk 1]
- Variablesset [AnimTicks] to (0)
- elseSecond slot of the same if/else blockVariableschange [AnimTicks] by (1)
- Controlif <AnimTicks > 3> then
- Looksnext costume
- Variablesset [AnimTicks] to (0)
- Controlif <Invincible > 0> then
- Variableschange [Invincible] by (-1)
- Controlif <<Invincible = 0> and <<<touching [Hazards]?> or <touching [Crawler]?>> or <<touching [Bat]?> or <y position < -170>>>> then
- Variablesset [GameState] to (hurt)
- Eventsbroadcast [player hit]
PlayerReset motion and give brief hit protection
- Eventswhen I receive [respawn]
- Motiongo to x: (-210) y: (-126)
- Variablesset [XSpeed] to (0)
- Variablesset [YSpeed] to (0)
- Variablesset [Grounded] to (0)
- Variablesset [JumpHeld] to (0)
- Variablesset [StepY] to (-1)
- Variablesset [AnimTicks] to (0)
- Looksswitch costume to [Walk 1]
- Motionset rotation style [left-right]
- Motionpoint in direction (90)
- Variablesset [Invincible] to (30)
- Looksshow
PlayerHide the explorer when a run ends
- Eventswhen I receive [game ended]
- Lookshide
CrawlerPlace and reset Crawler
- Eventswhen I receive [load level]
- Motiongo to x: (170) y: (-132)
- Variablesset [AnimTicks] to (0)
- Variablesset [Speed] to (2)
- Looksswitch costume to [1]
- Looksshow
CrawlerHide Crawler on the menu
- Eventswhen I receive [show menu]
- Lookshide
CrawlerPatrol the floor and animate the crawler
- Eventswhen green flag clicked
- Controlforever
- Controlif <GameState = playing> then
- Motionchange x by (Speed)
- Controlif <x position > 206> then
- Variablesset [Speed] to (-2)
- Controlif <x position < 154> then
- Variablesset [Speed] to (2)
- Variableschange [AnimTicks] by (1)
- Controlif <AnimTicks > 3> then
- Looksnext costume
- Variablesset [AnimTicks] to (0)
CrawlerHide Crawler when the run ends
- Eventswhen I receive [game ended]
- Lookshide
BatPlace and reset Bat
- Eventswhen I receive [load level]
- Motiongo to x: (0) y: (45)
- Variablesset [AnimTicks] to (0)
- Variablesset [Phase] to (0)
- Looksswitch costume to [1]
- Looksshow
BatHide Bat on the menu
- Eventswhen I receive [show menu]
- Lookshide
BatFly in a loop and animate the bat
- Eventswhen green flag clicked
- Controlforever
- Controlif <GameState = playing> then
- Variableschange [Phase] by (8)
- Motiongo to x: ((70) * (sin of (Phase))) y: ((45) + ((18) * (cos of (Phase))))
- Variableschange [AnimTicks] by (1)
- Controlif <AnimTicks > 3> then
- Looksnext costume
- Variablesset [AnimTicks] to (0)
BatHide Bat when the run ends
- Eventswhen I receive [game ended]
- Lookshide
HazardsLoad the level hazards costume
- Eventswhen I receive [load level]
- Motiongo to x: (0) y: (0)
- Looksswitch costume to [Level]
- Looksshow
HazardsHide hazards on the menu
- Eventswhen I receive [show menu]
- Lookshide
HazardsHide hazards on result screens
- Eventswhen I receive [game ended]
- Lookshide
StartShow New Game only on the menu
- Eventswhen green flag clicked
- Controlforever
- Controlif <GameState = menu> then
- Looksshow
- elseSecond slot of the same if/else blockLookshide
StartStart from the menu
- Eventswhen this sprite clicked
- Controlif <GameState = menu> then
- Eventsbroadcast [new game]
MenuShow Menu only when it can be used
- Eventswhen green flag clicked
- Controlforever
- Controlif <GameState = lost> then
- Looksshow
- Looksgo to [front] layer
- elseSecond slot of the same if/else blockLookshide
MenuUse the Menu control
- Eventswhen this sprite clicked
- Controlif <GameState = lost> then
- Eventsbroadcast [show menu]
Ready for the next step?
Return here anytime to review.
Lesson discussion
Ask a question or help a classmate. Mr. S can reply here.
Loading discussion…

















