Unit 3 · Lesson 1

Follow the trail through three areas

  • Areas, progress and saving
  • 90 minutes
  • Advanced Scratch · After Monster Quest

Earn crystals and unlock the next part of the adventure.

Recommended preparation: Scratch Monster Quest. Complete Monster Quest or bring equivalent Scratch experience. Build from a blank project, one small pictured action at a time.

Your goal

Keep one enemy defeat per area and carry progress into the next area.

Each area has one crystal to earn. A cleared flag remembers a victory, so returning to a defeated enemy cannot give another crystal.

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

  1. Select Stage’s thumbnail

    Upload the cavern

    Select Stage → Backdrops. Upload cavern-backdrop.png. Rename it Crystal Cavern. This will be area 2.

    Actual Scratch editor: Upload the cavern. Select Stage → Backdrops. Upload cavern-backdrop.png. Rename it Crystal Cavern. This will be area 2.
    1. Click: Open Backdrops
    2. Click: Point at Choose a Backdrop
    3. Click: Click Upload Backdrop
    4. Click: Rename this picture
    Actual Scratch editor · step 1
  2. Select Stage’s thumbnail

    Upload the ruins

    Upload ruins-backdrop.png as another backdrop. Rename it Ancient Ruins. This will be area 3.

    Actual Scratch editor: Upload the ruins. Upload ruins-backdrop.png as another backdrop. Rename it Ancient Ruins. This will be area 3.
    1. Click: Open Backdrops
    2. Click: Point at Choose a Backdrop
    3. Click: Click Upload Backdrop
    4. Click: Rename this picture
    Actual Scratch editor · step 2
  3. Select Stage’s thumbnail

    Upload the victory screen

    Upload win-screen.png as another backdrop. Rename it Adventure Complete. You will show this after earning the final crystal.

    Actual Scratch editor: Upload the victory screen. Upload win-screen.png as another backdrop. Rename it Adventure Complete. You will show this after earning the final crystal.
    1. Click: Open Backdrops
    2. Click: Point at Choose a Backdrop
    3. Click: Click Upload Backdrop
    4. Click: Rename this picture
    Actual Scratch editor · step 3
  4. Select Enemy

    Add the skeleton’s first costume

    Select Enemy → Costumes. Upload skeleton-idle.png. Rename it Skeleton 1. Add it to Enemy, not as a separate sprite.

    Actual Scratch editor: Add the skeleton’s first costume. Select Enemy → Costumes. Upload skeleton-idle.png. Rename it Skeleton 1. Add it to Enemy, not as a separate sprite.
    1. Click: Open Costumes
    2. Click: Point at Choose a Costume
    3. Click: Click Upload Costume
    4. Click: Rename this picture
    Actual Scratch editor · step 4
  5. Select Enemy

    Add the skeleton’s second costume

    Upload skeleton-blink.png as another Enemy costume. Rename it Skeleton 2. Keep the two Slime costumes.

    Actual Scratch editor: Add the skeleton’s second costume. Upload skeleton-blink.png as another Enemy costume. Rename it Skeleton 2. Keep the two Slime costumes.
    1. Click: Open Costumes
    2. Click: Point at Choose a Costume
    3. Click: Click Upload Costume
    4. Click: Rename this picture
    Actual Scratch editor · step 5
  6. Select Enemy

    Add the bat’s first costume

    Upload bat-idle.png as another Enemy costume. Rename it Bat 1. The final area will use this enemy.

    Actual Scratch editor: Add the bat’s first costume. Upload bat-idle.png as another Enemy costume. Rename it Bat 1. The final area will use this enemy.
    1. Click: Open Costumes
    2. Click: Point at Choose a Costume
    3. Click: Click Upload Costume
    4. Click: Rename this picture
    Actual Scratch editor · step 6
  7. Select Enemy

    Add the bat’s second costume

    Upload bat-blink.png as another Enemy costume. Rename it Bat 2. Enemy should now have six costumes.

    Actual Scratch editor: Add the bat’s second costume. Upload bat-blink.png as another Enemy costume. Rename it Bat 2. Enemy should now have six costumes.
    1. Click: Open Costumes
    2. Click: Point at Choose a Costume
    3. Click: Click Upload Costume
    4. Click: Rename this picture
    Actual Scratch editor · step 7
  8. Add Portal

    Upload the portal

    Upload portal.png as a new sprite. Rename it Portal. A cleared area will reveal the route onward.

    Actual Scratch editor: Upload the portal. Upload portal.png as a new sprite. Rename it Portal. A cleared area will reveal the route onward.
    1. Click: Point at Choose a Sprite
    2. Click: Click Upload Sprite
    Actual Scratch editor · step 8
  9. Select Portal

    Place Portal

    Select Portal. Set x to 205, y to 15, size to 200 and rotation style to do not rotate. It stands near the right edge of the path.

    Actual Scratch editor: Place Portal. Select Portal. Set x to 205, y to 15, size to 200 and rotation style to do not rotate. It stands near the right edge of the path.
    1. Click: Set the pictured x and y
    2. Click: Set the pictured size
    3. Click: Open Direction to choose no rotation
    Actual Scratch editor · step 9
  10. Select Stage’s thumbnail

    Create the progress counters

    Create HeroLevel and Crystals, each For all sprites. Uncheck their monitors for now. Area tells us the map; HeroLevel and Crystals let the player see their progress.

    Actual Scratch editor: Create the progress counters. Create HeroLevel and Crystals, each For all sprites. Uncheck their monitors for now. Area tells us the map; HeroLevel and Crystals let the player see their progress.
    1. Click: Type the variable name
    2. Check: This variable is shared by all sprites
    3. Click: Click OK
    Actual Scratch editor · step 10
  11. Select Stage’s thumbnail

    Reset visible progress

    Select Stage. Add set HeroLevel to 1 and set Crystals to 0 at the bottom of the green-flag reset stack.

    Actual Scratch editor: Reset visible progress. Select Stage. Add set HeroLevel to 1 and set Crystals to 0 at the bottom of the green-flag reset stack.
    1. Add: Add or update the highlighted blocks
    Actual Scratch editor · step 11
  12. Select Stage’s thumbnail

    Reset progress for New Game

    Add those same two progress resets to Stage’s new game stack, just after set Potions to 3. Keep ask hero name and load area below them.

    Actual Scratch editor: Reset progress for New Game. Add those same two progress resets to Stage’s new game stack, just after set Potions to 3. Keep ask hero name and load area below them.
    1. Add: Add or update the highlighted blocks
    Actual Scratch editor · step 12
  13. Select Stage’s thumbnail

    Choose the right area background

    In Stage’s load area stack, replace switch backdrop to Meadow Trail with the pictured if / else. Area 1 uses Meadow Trail; otherwise test Area 2 for Crystal Cavern, with Ancient Ruins in the final else.

    Actual Scratch editor: Choose the right area background. In Stage’s load area stack, replace switch backdrop to Meadow Trail with the pictured if / else. Area 1 uses Meadow Trail; otherwise test Area 2 for Crystal Cavern, with Ancient Ruins in the final else.
    1. Add: Add or update the highlighted blocks
    Actual Scratch editor · step 13
  14. Select Stage’s thumbnail

    Calculate progress when an area loads

    At the bottom of that stack, set HeroLevel to Area, then set Crystals to (Area − 1) + Cleared. Earlier completed areas each count as one crystal.

    Actual Scratch editor: Calculate progress when an area loads. At the bottom of that stack, set HeroLevel to Area, then set Crystals to (Area − 1) + Cleared. Earlier completed areas each count as one crystal.
    1. Add: Build these blocks in this order
    Actual Scratch editor · step 14
  15. Select Stage’s thumbnail

    Show the progress counters

    In Stage’s information loop, add show variable Area, HeroLevel and Crystals beside the existing show-variable blocks. Keep them in the first slot of the playing-state if.

    Actual Scratch editor: Show the progress counters. In Stage’s information loop, add show variable Area, HeroLevel and Crystals beside the existing show-variable blocks. Keep them in the first slot of the playing-state if.
    1. Add: Add or update the highlighted blocks
    Actual Scratch editor · step 15
  16. Select Stage’s thumbnail

    Hide progress outside the adventure

    Add hide variable Area, HeroLevel and Crystals to the matching else slot. Keep the separate Message and EnemyHP checks below this if.

    Actual Scratch editor: Hide progress outside the adventure. Add hide variable Area, HeroLevel and Crystals to the matching else slot. Keep the separate Message and EnemyHP checks below this if.
    1. Add: Add or update the highlighted blocks
    Actual Scratch editor · step 16
  17. Select Enemy

    Choose the area’s enemy

    Select Enemy’s load area stack. Replace its single costume block with the pictured nested if / else: Area 1 → Slime 1; Area 2 → Skeleton 1; otherwise → Bat 1.

    Actual Scratch editor: Choose the area’s enemy. Select Enemy’s load area stack. Replace its single costume block with the pictured nested if / else: Area 1 → Slime 1; Area 2 → Skeleton 1; otherwise → Bat 1.
    1. Add: Add or update the highlighted blocks
    Actual Scratch editor · step 17
  18. Select Enemy

    Return blinking to the right enemy

    In Enemy’s animation loop, replace switch costume to Slime 1 with the same three-area costume choice. Keep it inside if AnimTicks > 21, before resetting AnimTicks to 0.

    Actual Scratch editor: Return blinking to the right enemy. In Enemy’s animation loop, replace switch costume to Slime 1 with the same three-area costume choice. Keep it inside if AnimTicks > 21, before resetting AnimTicks to 0.
    1. Add: Add or update the highlighted blocks
    Actual Scratch editor · step 18
  19. Select Enemy

    Keep the correct enemy in battle

    In Enemy’s start battle stack, replace the Slime 1 costume block with that same three-area costume choice. Keep go to x: 105 y: −15 first.

    Actual Scratch editor: Keep the correct enemy in battle. In Enemy’s start battle stack, replace the Slime 1 costume block with that same three-area costume choice. Keep go to x: 105 y: −15 first.
    1. Add: Add or update the highlighted blocks
    Actual Scratch editor · step 19
  20. Select Portal

    Load Portal in each area

    Select Portal. Make when I receive load area → go to x: 205 y: 15. All three maps share this exit position.

    Actual Scratch editor: Load Portal in each area. Select Portal. Make when I receive load area → go to x: 205 y: 15. All three maps share this exit position.
    1. Add: Build these blocks in this order
    Actual Scratch editor · step 20
  21. Select Portal

    Reveal Portal after a victory

    Build Portal’s pictured visibility loop. Require Cleared = 1 and GameState equal to explore, dialogue or save. The save state is for next lesson’s code screen. Otherwise hide.

    Actual Scratch editor: Reveal Portal after a victory. Build Portal’s pictured visibility loop. Require Cleared = 1 and GameState equal to explore, dialogue or save. The save state is for next lesson’s code screen. Otherwise hide.
    1. Add: Build these blocks in this order
    Actual Scratch editor · step 21
  22. Select Stage’s thumbnail

    Earn one crystal per area

    Select Stage’s battle won stack. Add set Crystals to Area before load area. Change Message to Crystal earned! Walk to Portal. Cleared stays 1, preventing another reward from this foe.

    Actual Scratch editor: Earn one crystal per area. Select Stage’s battle won stack. Add set Crystals to Area before load area. Change Message to Crystal earned! Walk to Portal. Cleared stays 1, preventing another reward from this foe.
    1. Add: Add or update the highlighted blocks
    Actual Scratch editor · step 22
  23. Select Guide

    Point the player toward Portal

    In Guide’s YES branch, change the already-cleared reply to Area clear. Walk to Portal. Keep the existing check that only an unbeaten area can accept a quest.

    Actual Scratch editor: Point the player toward Portal. In Guide’s YES branch, change the already-cleared reply to Area clear. Walk to Portal. Keep the existing check that only an unbeaten area can accept a quest.
    1. Add: Add or update the highlighted blocks
    Actual Scratch editor · step 23
  24. Select Hero

    Detect entering Portal

    Select Hero. Build the pictured green-flag loop. If GameState = explore, Cleared = 1 and touching Portal, set GameState to travel and broadcast next area.

    Actual Scratch editor: Detect entering Portal. Select Hero. Build the pictured green-flag loop. If GameState = explore, Cleared = 1 and touching Portal, set GameState to travel and broadcast next area.
    1. Add: Build these blocks in this order
    Actual Scratch editor · step 24
  25. Select Stage’s thumbnail

    Prepare the next area

    Select Stage. Begin when I receive next area. Inside if Area < 3, change Area by 1, set Cleared to 0 and set QuestReady to 0. Put the following travel blocks in this same slot.

    Actual Scratch editor: Prepare the next area. Select Stage. Begin when I receive next area. Inside if Area < 3, change Area by 1, set Cleared to 0 and set QuestReady to 0. Put the following travel blocks in this same slot.
    1. Add: Add or update the highlighted blocks
    Actual Scratch editor · step 25
  26. Select Stage’s thumbnail

    Increase strength and load the map

    Continue that first slot. Recalculate MaxHP as 10 + (2 × Area) and Power as Area + 2. Set HP to MaxHP, broadcast load area and wait, then set GameState to explore. Keep Potions unchanged.

    Actual Scratch editor: Increase strength and load the map. Continue that first slot. Recalculate MaxHP as 10 + (2 × Area) and Power as Area + 2. Set HP to MaxHP, broadcast load area and wait, then set GameState to explore. Keep Potions unchanged.
    1. Add: Add or update the highlighted blocks
    Actual Scratch editor · step 26
  27. Select Stage’s thumbnail

    Finish after the final crystal

    In that if’s else slot, set GameState to won, set Message to Adventure complete!, and switch backdrop to Adventure Complete. This slot runs when Area is already 3.

    Actual Scratch editor: Finish after the final crystal. In that if’s else slot, set GameState to won, set Message to Adventure complete!, and switch backdrop to Adventure Complete. This slot runs when Area is already 3.
    1. Add: Add or update the highlighted blocks
    Actual Scratch editor · step 27
  28. Select Menu

    Show Menu after winning too

    Select Menu’s visibility loop. Change its condition to GameState = lost or GameState = won. The same button now works on both ending screens.

    Actual Scratch editor: Show Menu after winning too. Select Menu’s visibility loop. Change its condition to GameState = lost or GameState = won. The same button now works on both ending screens.
    1. Add: Add or update the highlighted blocks
    Actual Scratch editor · step 28
  29. Select Menu

    Allow the winning Menu click

    Update Menu’s click-stack condition to the same lost or won test. Keep set GameState to leaving and broadcast show menu inside it.

    Actual Scratch editor: Allow the winning Menu click. Update Menu’s click-stack condition to the same lost or won test. Keep set GameState to leaving and broadcast show menu inside it.
    1. Add: Add or update the highlighted blocks
    Actual Scratch editor · step 29
  30. Select Stage’s thumbnail

    Test the first portal

    Drag Area, HeroLevel and Crystals onto the second row, matching the picture. Win in Meadow Trail, then enter Portal. Crystal Cavern loads with the skeleton: Area and HeroLevel become 2, HP is 14, and Potions keeps its earlier count.

    Actual Scratch editor: Test the first portal. Drag Area, HeroLevel and Crystals onto the second row, matching the picture. Win in Meadow Trail, then enter Portal. Crystal Cavern loads with the skeleton: Area and HeroLevel become 2, HP is 14, and Potions keeps its earlier count.
    1. Click: Run your test with the green flag
    2. Check: Arrange these counters to match
    3. Check: Read the Message after testing
    Actual Scratch editor · step 30
  31. Select Stage’s thumbnail

    Test the final challenge

    Earn the second crystal, then enter Ancient Ruins. Use REST if you need a potion, then accept the bat quest. Attack three times, Heal, then finish the fight. Earn crystal 3 and enter Portal. Adventure Complete should appear.

    Actual Scratch editor: Test the final challenge. Earn the second crystal, then enter Ancient Ruins. Use REST if you need a potion, then accept the bat quest. Attack three times, Heal, then finish the fight. Earn crystal 3 and enter Portal. Adventure Complete should appear.
    1. Click: Run your test with the green flag
    2. Check: Check the Adventure Complete screen
    3. Click: Click Menu to play again
    Actual Scratch editor · step 31
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 8.

Download lesson 8 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
  1. Eventswhen green flag clicked
  2. Variablesset [GameState] to (menu)
  3. Looksswitch backdrop to [Title Screen]
  4. Variablesset [HeroName] to (Explorer)
  5. Variablesset [Message] to ()
  6. Variablesset [QuestReady] to (0)
  7. Variablesset [Area] to (1)
  8. Variablesset [Cleared] to (0)
  9. Variablesset [MaxHP] to ((10) + ((2) * (Area)))
  10. Variablesset [Power] to ((Area) + (2))
  11. Variablesset [HP] to (MaxHP)
  12. Variablesset [EnemyHP] to (0)
  13. Variablesset [EnemyPower] to (0)
  14. Variablesset [Potions] to (3)
  15. Variablesset [HeroLevel] to (1)
  16. Variablesset [Crystals] to (0)
StageReset progress and begin
  1. Eventswhen I receive [new game]
  2. Variablesset [QuestReady] to (0)
  3. Variablesset [Area] to (1)
  4. Variablesset [Cleared] to (0)
  5. Variablesset [MaxHP] to ((10) + ((2) * (Area)))
  6. Variablesset [Power] to ((Area) + (2))
  7. Variablesset [HP] to (MaxHP)
  8. Variablesset [EnemyHP] to (0)
  9. Variablesset [EnemyPower] to (0)
  10. Variablesset [Potions] to (3)
  11. Variablesset [HeroLevel] to (1)
  12. Variablesset [Crystals] to (0)
  13. Eventsbroadcast [ask hero name] and wait
  14. Eventsbroadcast [load area] and wait
  15. Variablesset [GameState] to (explore)
StageShow the current area
  1. Eventswhen I receive [load area]
  2. Controlif <Area = 1> then
  3. Looksswitch backdrop to [Meadow Trail]
  4. elseSecond slot of the same if/else block
    Controlif <Area = 2> then
  5. Looksswitch backdrop to [Crystal Cavern]
  6. elseSecond slot of the same if/else block
    Looksswitch backdrop to [Ancient Ruins]
  7. Variablesset [Message] to (Click Guide. Type YES to begin.)
  8. Variablesset [HeroLevel] to (Area)
  9. Variablesset [Crystals] to (((Area) - (1)) + (Cleared))
StageAsk for a short hero nickname
  1. Eventswhen I receive [ask hero name]
  2. Variablesset [GameState] to (naming)
  3. Sensingask [Choose a made-up hero nickname (1–12 letters).] and wait
  4. Variablesset [HeroName] to (answer)
  5. Controlif <<length of [HeroName] = 0> or <length of [HeroName] > 12>> then
  6. Variablesset [HeroName] to (Explorer)
StageShow information only while playing
  1. Eventswhen green flag clicked
  2. Controlforever
  3. Controlif <<<GameState = explore> or <GameState = dialogue>> or <<<GameState = battle> or <GameState = turn>> or <GameState = loading>>> then
  4. Variablesshow variable [HeroName]
  5. Variablesshow variable [HP]
  6. Variablesshow variable [MaxHP]
  7. Variablesshow variable [Potions]
  8. Variablesshow variable [Area]
  9. Variablesshow variable [HeroLevel]
  10. Variablesshow variable [Crystals]
  11. elseSecond slot of the same if/else block
    Variableshide variable [HeroName]
  12. Variableshide variable [HP]
  13. Variableshide variable [MaxHP]
  14. Variableshide variable [Potions]
  15. Variableshide variable [Area]
  16. Variableshide variable [HeroLevel]
  17. Variableshide variable [Crystals]
  18. Controlif <not <Message = >> then
  19. Variablesshow variable [Message]
  20. elseSecond slot of the same if/else block
    Variableshide variable [Message]
  21. Controlif <<GameState = battle> or <GameState = turn>> then
  22. Variablesshow variable [EnemyHP]
  23. elseSecond slot of the same if/else block
    Variableshide variable [EnemyHP]
StageSet up a fair battle
  1. Eventswhen I receive [start battle]
  2. Variablesset [GameState] to (turn)
  3. Variablesset [EnemyHP] to ((8) * (Area))
  4. Variablesset [EnemyPower] to ((Area) + (1))
  5. Looksswitch backdrop to [Battle Arena]
  6. Variablesset [Message] to (Choose one battle action.)
  7. Variablesset [GameState] to (battle)
StageAttack once, then give the enemy a turn
  1. Eventswhen I receive [hero attack]
  2. Variableschange [EnemyHP] by ((0) - (Power))
  3. Controlif <EnemyHP < 0> then
  4. Variablesset [EnemyHP] to (0)
  5. Variablesset [Message] to (Your hero attacks!)
  6. Eventsbroadcast [enemy hurt] and wait
  7. Controlif <EnemyHP < 1> then
  8. Eventsbroadcast [battle won]
  9. elseSecond slot of the same if/else block
    Eventsbroadcast [enemy turn]
StageResolve one enemy attack
  1. Eventswhen I receive [enemy turn]
  2. Controlwait (0.25) seconds
  3. Variableschange [HP] by ((0) - (EnemyPower))
  4. Controlif <HP < 0> then
  5. Variablesset [HP] to (0)
  6. Variablesset [Message] to (The enemy strikes back!)
  7. Eventsbroadcast [hero hurt] and wait
  8. Controlif <HP < 1> then
  9. Variablesset [GameState] to (lost)
  10. Looksswitch backdrop to [Try Again]
  11. elseSecond slot of the same if/else block
    Variablesset [Message] to (Your turn: Attack, Heal or Run.)
  12. Variablesset [GameState] to (battle)
StageClear the area once
  1. Eventswhen I receive [battle won]
  2. Variablesset [Cleared] to (1)
  3. Variablesset [QuestReady] to (0)
  4. Variablesset [Crystals] to (Area)
  5. Eventsbroadcast [load area] and wait
  6. Variablesset [Message] to (Crystal earned! Walk to Portal.)
  7. Variablesset [GameState] to (explore)
StageUse one potion and give the enemy a turn
  1. Eventswhen I receive [heal hero]
  2. Variableschange [Potions] by (-1)
  3. Variableschange [HP] by (6)
  4. Controlif <HP > MaxHP> then
  5. Variablesset [HP] to (MaxHP)
  6. Variablesset [Message] to (Potion restores up to 6 HP.)
  7. Controlwait (0.3) seconds
  8. Eventsbroadcast [enemy turn]
StageRetreat without earning a crystal
  1. Eventswhen I receive [run away]
  2. Eventsbroadcast [load area] and wait
  3. Variablesset [Message] to (Retreated. HP and potions stay.)
  4. Variablesset [GameState] to (explore)
StageReturn to the title screen
  1. Eventswhen I receive [show menu]
  2. Variablesset [GameState] to (menu)
  3. Looksswitch backdrop to [Title Screen]
  4. Variablesset [Message] to ()
StageTravel onward or finish the adventure
  1. Eventswhen I receive [next area]
  2. Controlif <Area < 3> then
  3. Variableschange [Area] by (1)
  4. Variablesset [Cleared] to (0)
  5. Variablesset [QuestReady] to (0)
  6. Variablesset [MaxHP] to ((10) + ((2) * (Area)))
  7. Variablesset [Power] to ((Area) + (2))
  8. Variablesset [HP] to (MaxHP)
  9. Eventsbroadcast [load area] and wait
  10. Variablesset [GameState] to (explore)
  11. elseSecond slot of the same if/else block
    Variablesset [GameState] to (won)
  12. Variablesset [Message] to (Adventure complete!)
  13. Looksswitch backdrop to [Adventure Complete]
StartShow New Game on the title screen
  1. Eventswhen green flag clicked
  2. Controlforever
  3. Controlif <GameState = menu> then
  4. Looksshow
  5. elseSecond slot of the same if/else block
    Lookshide
StartLock New Game before starting
  1. Eventswhen this sprite clicked
  2. Controlif <GameState = menu> then
  3. Variablesset [GameState] to (loading)
  4. Eventsbroadcast [new game]
HeroPlace the hero at a safe starting point
  1. Eventswhen I receive [load area]
  2. Looksclear graphic effects
  3. Motiongo to x: (-180) y: (-80)
  4. Variablesset [XSpeed] to (0)
  5. Variablesset [YSpeed] to (0)
  6. Variablesset [AnimTicks] to (0)
  7. Looksswitch costume to [Stand]
  8. Motionset rotation style [left-right]
  9. Motionpoint in direction (90)
HeroShow the hero only inside the adventure
  1. Eventswhen green flag clicked
  2. Controlforever
  3. Controlif <<<GameState = explore> or <GameState = dialogue>> or <<GameState = battle> or <GameState = turn>>> then
  4. Looksshow
  5. elseSecond slot of the same if/else block
    Lookshide
HeroRead arrow keys and move in four directions
  1. Eventswhen green flag clicked
  2. Controlforever
  3. Controlif <GameState = explore> then
  4. Variablesset [XSpeed] to (0)
  5. Variablesset [YSpeed] to (0)
  6. Controlif <key [left arrow] pressed?> then
  7. Variableschange [XSpeed] by (-4)
  8. Controlif <key [right arrow] pressed?> then
  9. Variableschange [XSpeed] by (4)
  10. Controlif <key [up arrow] pressed?> then
  11. Variableschange [YSpeed] by (4)
  12. Controlif <key [down arrow] pressed?> then
  13. Variableschange [YSpeed] by (-4)
  14. Motionchange x by (XSpeed)
  15. Motionchange y by (YSpeed)
  16. My Blocksstay on map
HeroStay inside the map
  1. My Blocksdefine stay on map
  2. Controlif <x position > 215> then
  3. Motionset x to (215)
  4. Controlif <x position < -215> then
  5. Motionset x to (-215)
  6. Controlif <y position > 85> then
  7. Motionset y to (85)
  8. Controlif <y position < -120> then
  9. Motionset y to (-120)
HeroFace the way you move and animate your feet
  1. Eventswhen green flag clicked
  2. Controlforever
  3. Controlif <GameState = explore> then
  4. Controlif <XSpeed < 0> then
  5. Motionpoint in direction (-90)
  6. Controlif <XSpeed > 0> then
  7. Motionpoint in direction (90)
  8. Controlif <<XSpeed = 0> and <YSpeed = 0>> then
  9. Looksswitch costume to [Stand]
  10. Variablesset [AnimTicks] to (0)
  11. elseSecond slot of the same if/else block
    Variableschange [AnimTicks] by (1)
  12. Controlif <AnimTicks > 3> then
  13. Looksnext costume
  14. Variablesset [AnimTicks] to (0)
HeroStand on the left for battle
  1. Eventswhen I receive [start battle]
  2. Motiongo to x: (-105) y: (-15)
  3. Looksswitch costume to [Stand]
  4. Motionpoint in direction (90)
HeroBegin a quest battle by touching the enemy
  1. Eventswhen green flag clicked
  2. Controlforever
  3. Controlif <<GameState = explore> and <<<QuestReady = 1> and <Cleared = 0>> and <touching [Enemy]?>>> then
  4. Variablesset [GameState] to (loading battle)
  5. Eventsbroadcast [start battle]
HeroFlash when the enemy hits
  1. Eventswhen I receive [hero hurt]
  2. Looksset [color] effect to (40)
  3. Motionchange x by (-6)
  4. Controlwait (0.12) seconds
  5. Motionchange x by (6)
  6. Looksclear graphic effects
HeroEnter the portal after earning a crystal
  1. Eventswhen green flag clicked
  2. Controlforever
  3. Controlif <<GameState = explore> and <<Cleared = 1> and <touching [Portal]?>>> then
  4. Variablesset [GameState] to (travel)
  5. Eventsbroadcast [next area]
GuidePlace the guide beside the path
  1. Eventswhen I receive [load area]
  2. Motiongo to x: (-75) y: (25)
GuideShow the guide on the map
  1. Eventswhen green flag clicked
  2. Controlforever
  3. Controlif <<GameState = explore> or <GameState = dialogue>> then
  4. Looksshow
  5. elseSecond slot of the same if/else block
    Lookshide
GuideListen to the player’s typed choice
  1. Eventswhen this sprite clicked
  2. Controlif <GameState = explore> then
  3. Variablesset [GameState] to (dialogue)
  4. Sensingask [Type YES for quest, HINT for help, or REST to recover.] and wait
  5. Controlif <answer = YES> then
  6. Controlif <Cleared = 0> then
  7. Variablesset [QuestReady] to (1)
  8. Variablesset [Message] to (Walk to the monster to battle.)
  9. elseSecond slot of the same if/else block
    Variablesset [Message] to (Area clear. Walk to Portal.)
  10. elseSecond slot of the same if/else block
    Controlif <answer = HINT> then
  11. Variablesset [Message] to (Arrows move. Touch foe after YES.)
  12. elseSecond slot of the same if/else block
    Controlif <answer = REST> then
  13. Variablesset [HP] to (MaxHP)
  14. Controlif <Potions = 0> then
  15. Variablesset [Potions] to (1)
  16. Variablesset [Message] to (Rested! At least one potion ready.)
  17. elseSecond slot of the same if/else block
    Variablesset [Message] to (Try YES, HINT or REST.)
  18. Variablesset [GameState] to (explore)
EnemyChoose the monster for this area
  1. Eventswhen I receive [load area]
  2. Looksclear graphic effects
  3. Motiongo to x: (125) y: (-30)
  4. Variablesset [AnimTicks] to (0)
  5. Controlif <Area = 1> then
  6. Looksswitch costume to [Slime 1]
  7. elseSecond slot of the same if/else block
    Controlif <Area = 2> then
  8. Looksswitch costume to [Skeleton 1]
  9. elseSecond slot of the same if/else block
    Looksswitch costume to [Bat 1]
EnemyHide a defeated enemy
  1. Eventswhen green flag clicked
  2. Controlforever
  3. Controlif <<<<<GameState = explore> or <GameState = dialogue>> or <GameState = loading battle>> and <Cleared = 0>> or <<GameState = battle> or <GameState = turn>>> then
  4. Looksshow
  5. elseSecond slot of the same if/else block
    Lookshide
EnemyBlink while waiting for the hero
  1. Eventswhen green flag clicked
  2. Controlforever
  3. Controlif <<GameState = explore> or <GameState = battle>> then
  4. Variableschange [AnimTicks] by (1)
  5. Controlif <AnimTicks = 18> then
  6. Looksnext costume
  7. Controlif <AnimTicks > 21> then
  8. Controlif <Area = 1> then
  9. Looksswitch costume to [Slime 1]
  10. elseSecond slot of the same if/else block
    Controlif <Area = 2> then
  11. Looksswitch costume to [Skeleton 1]
  12. elseSecond slot of the same if/else block
    Looksswitch costume to [Bat 1]
  13. Variablesset [AnimTicks] to (0)
EnemyFace the hero across the battle arena
  1. Eventswhen I receive [start battle]
  2. Motiongo to x: (105) y: (-15)
  3. Controlif <Area = 1> then
  4. Looksswitch costume to [Slime 1]
  5. elseSecond slot of the same if/else block
    Controlif <Area = 2> then
  6. Looksswitch costume to [Skeleton 1]
  7. elseSecond slot of the same if/else block
    Looksswitch costume to [Bat 1]
EnemyFlash and recoil when hit
  1. Eventswhen I receive [enemy hurt]
  2. Looksset [color] effect to (40)
  3. Motionchange x by (6)
  4. Controlwait (0.12) seconds
  5. Motionchange x by (-6)
  6. Looksclear graphic effects
PortalPlace the portal at the right edge
  1. Eventswhen I receive [load area]
  2. Motiongo to x: (205) y: (15)
PortalShow the portal only after the battle is won
  1. Eventswhen green flag clicked
  2. Controlforever
  3. Controlif <<<<GameState = explore> or <GameState = dialogue>> or <GameState = save>> and <Cleared = 1>> then
  4. Looksshow
  5. elseSecond slot of the same if/else block
    Lookshide
AttackShow Attack when it can be used
  1. Eventswhen green flag clicked
  2. Controlforever
  3. Controlif <GameState = battle> then
  4. Looksshow
  5. elseSecond slot of the same if/else block
    Lookshide
AttackUse Attack once per turn
  1. Eventswhen this sprite clicked
  2. Controlif <GameState = battle> then
  3. Variablesset [GameState] to (turn)
  4. Eventsbroadcast [hero attack]
HealShow Heal when it can be used
  1. Eventswhen green flag clicked
  2. Controlforever
  3. Controlif <GameState = battle> then
  4. Looksshow
  5. elseSecond slot of the same if/else block
    Lookshide
HealUse Heal once per turn
  1. Eventswhen this sprite clicked
  2. Controlif <GameState = battle> then
  3. Controlif <<Potions > 0> and <HP < MaxHP>> then
  4. Variablesset [GameState] to (turn)
  5. Eventsbroadcast [heal hero]
  6. elseSecond slot of the same if/else block
    Variablesset [Message] to (Need missing HP and a potion.)
RunShow Run when it can be used
  1. Eventswhen green flag clicked
  2. Controlforever
  3. Controlif <GameState = battle> then
  4. Looksshow
  5. elseSecond slot of the same if/else block
    Lookshide
RunUse Run once per turn
  1. Eventswhen this sprite clicked
  2. Controlif <GameState = battle> then
  3. Variablesset [GameState] to (retreat)
  4. Eventsbroadcast [run away]
MenuShow Menu when it can be used
  1. Eventswhen green flag clicked
  2. Controlforever
  3. Controlif <<GameState = lost> or <GameState = won>> then
  4. Looksshow
  5. elseSecond slot of the same if/else block
    Lookshide
MenuKeep Menu clear of the save code
  1. Eventswhen green flag clicked
  2. Controlforever
  3. Motiongo to x: (0) y: (-80)
MenuUse Menu once per turn
  1. Eventswhen this sprite clicked
  2. Controlif <<GameState = lost> or <GameState = won>> then
  3. Variablesset [GameState] to (leaving)
  4. Eventsbroadcast [show menu]
END OF LESSON

Ready for the next step?

Return here anytime to review.

Comments

Lesson discussion

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

Loading discussion…