Install MyHighschool on your device for quick access

Add to Home Screen (iPhone & iPad)

  1. Tap the Share button (square with an arrow pointing up).
  2. Scroll down and tap Add to Home Screen.
  3. Tap Add to confirm.

Install or add to your home screen

This browser does not support the automatic install banner. Open the menu (often or ) and look for Install, Add app, or Add to Home Screen.

MyHighschool
Chapter 3

Locker Dash

Locker Dash — dodge the hallway

Sign in to download the sprite starter .sb3 for this chapter.

Use the manual below to learn the ideas and build the lab in Scratch — download the sprite starter under the chapter title first. (~27 min)

Build Locker Dash — dodge moving obstacles with arrow keys while a timer or distance variable tracks how long you survive the hallway.

What you will learn in this chapter

Key events

Events

when key pressed arrow keys move your runner left and right without leaving the stage.

Touching detection

Sensing

touching another sprite or color ends the run or costs a life.

Obstacle motion

Motion · Control

Glide or change x in a loop so lockers and backpacks slide toward the player.

Survival variable

Variables

A timer or distance variable proves how far you got before a crash.

Green-flag reset

Events

Green flag returns the player, obstacles, and score to the starting hallway.

Read the ideas below, then follow the build steps in Scratch to make A hallway runner where you steer a student sprite left and right to dodge lockers and reach the exit.. When you are ready, continue to the concept check.

How this chapter works

  • Step 1 — Read and build from this manual (learn the ideas, then follow Part B in Scratch).
  • Step 2 — Pass the concept check on the course page.
  • Step 3 — Submit on the course page when your project matches the checklist.
  • Step 4 — Optional bonus: extend your project for two players (unlocks after you submit).

Work in order: learn the ideas first, pass the concept check on the course page, then build the lab below. Save your Scratch project at each save point.

Learn the ideas

By the end of this chapter you will build: A hallway runner where you steer a student sprite left and right to dodge lockers and reach the exit.

Build Locker Dash — dodge moving obstacles with arrow keys while a timer or distance variable tracks how long you survive the hallway.

What you will learn in this chapter

  • Key events (Events) — when key pressed arrow keys move your runner left and right without leaving the stage.
  • Touching detection (Sensing) — touching another sprite or color ends the run or costs a life.
  • Obstacle motion (Motion · Control) — Glide or change x in a loop so lockers and backpacks slide toward the player.
  • Survival variable (Variables) — A timer or distance variable proves how far you got before a crash.
  • Green-flag reset (Events) — Green flag returns the player, obstacles, and score to the starting hallway.

After this chapter you can

  • Steer a sprite with arrow keys smoothly
  • Spawn or move at least two obstacle types
  • End the run when the player hits an obstacle
  • Show survival time or distance and reset on green flag

Study the ideas below, then pass the concept check on the course page before you build the lab in Scratch.

School hallways are obstacle courses — and so is Locker Dash. You control a student dodging lockers sliding across the corridor. This chapter teaches smooth keyboard control and how to detect when something goes wrong.

Studio Cat: Studio Cat says: if you crash into every locker, you are gathering excellent collision data. Slow down the obstacles before you blame your reflexes.

Sketch first

Draw a top-down hallway: your sprite in the middle lane, three locker obstacles at different heights, and a star marking the finish line at the top.

Always-on movement

Games feel better when the player holds a key instead of tapping repeatedly. Use forever from Control with if key pressed from Sensing to check arrow keys every frame.

Key vocabulary

Collision When two sprites overlap or touch each other.
Forever loop A block that repeats its contents without stopping.
Coordinate An x,y position on the Stage — x is left/right, y is up/down.
Reset Returning sprites and variables to their starting values.

Build the chapter lab

Follow each part in Scratch while you read — use save points in Part B below. When your project matches the checklist, pass the concept check and submit on the course page.

Your lab for this chapter: A hallway runner where you steer a student sprite left and right to dodge lockers and reach the exit.

Part A - Steer the student down the hallway

Studio Cat: Sprite starter file. Before you build in Scratch, open this chapter on MyHighschool and click the green Download sprite starter (.sb3) button under the chapter title (you can also use it again in Step 1 — Read & Build). Open the file in Scratch — sprites and backdrops are already named. The starter has no scripts; add blocks from Part B of this manual.

Build the player first: a student sprite at the bottom that glides up the hallway while you dodge left and right.

Build steps

  1. Download the sprite starter with the green button under the chapter title on the MyHighschool page, then open it in Scratch.
  2. Rename the project Locker Dash if needed — Student, lockers, and hallway backdrop are ready.
  3. On the Student sprite, add when green flag clicked from Events.
  4. Snap on go to x: (0) y: (-150) from Motion to set the start position at the bottom.
  5. Add forever from Control. Inside it, add two if checks using key (left arrow) pressed? and key (right arrow) pressed? from Sensing.
  6. Under the left-key if, put change x by (-8); under the right-key if, put change x by (8) — both from Motion.
  7. After the forever loop (same green-flag script), add repeat until touching color (exit color) or use change y by (3) inside forever to auto-walk upward — pick one forward motion style and test it.
  8. Add a second if inside forever: if touching edge? from Sensing, then set x to (0) or bounce back so the student cannot leave the hallway.
  9. Click green flag: the student should move forward while arrow keys steer left and right smoothly.

Save point

Student steering works. Test arrow keys for ten seconds, then save.

Part B - Add sliding lockers and game over

Spawn locker obstacles that slide across the hallway. Touching one stops the run — then green flag lets you try again instantly.

Clone-like obstacles

You can duplicate a Locker sprite and give each copy its own script, or use create clone of myself later. For now, two or three locker sprites with different start times create the dash feeling.

Build steps

  1. The sprite starter includes two obstacle sprites — give each its own script, or duplicate Locker as shown below.
  2. On Locker 1, add when green flag clicked, then go to x: (-200) y: (50) from Motion.
  3. Add forever with change x by (4) inside so the locker slides right across the hallway.
  4. Inside the same forever, add if touching Student? from Control + Sensing.
  5. Inside that if, add say Game Over! for 1 seconds from Looks, then stop all from Control.
  6. Duplicate the locker sprite (right-click → duplicate). Change the copy's start y position and speed (change x by (6)) so obstacles feel different.
  7. Add a Finish sprite or colored tile at the top. On the Student script, add if touching Finish? then say You made it! for 2 seconds for a win state.
  8. Play five runs: confirm crashes stop the game and green flag resets everything cleanly.

Save point

Locker Dash has obstacles and win/lose states. Full play-test, then save.

Check yourself before the quiz

  1. Why use a forever loop to check arrow keys instead of one block per key press?
  2. What block tells Scratch that the student hit a locker?
  3. How does green flag help after a game over?
  4. What is the difference between losing (touch locker) and winning (touch finish)?

Confirm action