Locker Dash
Locker Dash — dodge the hallway
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
Eventswhen key pressed arrow keys move your runner left and right without leaving the stage.
Touching detection
Sensingtouching another sprite or color ends the run or costs a life.
Obstacle motion
Motion · ControlGlide or change x in a loop so lockers and backpacks slide toward the player.
Survival variable
VariablesA timer or distance variable proves how far you got before a crash.
Green-flag reset
EventsGreen flag returns the player, obstacles, and score to the starting hallway.
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.
Sketch first
Always-on movement
forever from Control with if key pressed from Sensing to check arrow keys every frame.Smooth steering — forever loop checks keys
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
Build the player first: a student sprite at the bottom that glides up the hallway while you dodge left and right.
Build steps
- Download the sprite starter with the green button under the chapter title on the MyHighschool page, then open it in Scratch.
- Rename the project
Locker Dashif needed — Student, lockers, and hallway backdrop are ready. - On the Student sprite, add
when green flag clickedfrom Events. - Snap on
go to x: (0) y: (-150)from Motion to set the start position at the bottom. - Add
foreverfrom Control. Inside it, add twoifchecks usingkey (left arrow) pressed?andkey (right arrow) pressed?from Sensing. - Under the left-key
if, putchange x by (-8); under the right-keyif, putchange x by (8)— both from Motion. - After the forever loop (same green-flag script), add
repeat until touching color (exit color)or usechange y by (3)inside forever to auto-walk upward — pick one forward motion style and test it. - Add a second
ifinside forever:if touching edge?from Sensing, thenset x to (0)or bounce back so the student cannot leave the hallway. - Click green flag: the student should move forward while arrow keys steer left and right smoothly.
Forward motion plus edge safety
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
create clone of myself later. For now, two or three locker sprites with different start times create the dash feeling.One locker obstacle — slide and detect crash
Build steps
- The sprite starter includes two obstacle sprites — give each its own script, or duplicate Locker as shown below.
- On Locker 1, add
when green flag clicked, thengo to x: (-200) y: (50)from Motion. - Add
foreverwithchange x by (4)inside so the locker slides right across the hallway. - Inside the same forever, add
if touching Student?from Control + Sensing. - Inside that
if, addsay Game Over! for 1 secondsfrom Looks, thenstop allfrom Control. - Duplicate the locker sprite (right-click → duplicate). Change the copy's start y position and speed (
change x by (6)) so obstacles feel different. - Add a Finish sprite or colored tile at the top. On the Student script, add
if touching Finish?thensay You made it! for 2 secondsfor a win state. - Play five runs: confirm crashes stop the game and green flag resets everything cleanly.
Student reset stack — reliable restart
Save point
Locker Dash has obstacles and win/lose states. Full play-test, then save.
Check yourself before the quiz
- Why use a
foreverloop to check arrow keys instead of one block per key press? - What block tells Scratch that the student hit a locker?
- How does green flag help after a game over?
- What is the difference between losing (touch locker) and winning (touch finish)?
Submit when the checklist matches your project.
Submission unlocks after you pass the concept check
Read and build from the manual in Step 1, pass the quiz in Step 2, then submit here.
Back to concept checkAlready submitted your project? Extend it so two people can play on one keyboard — this step is optional and does not change your homework grade.
Bonus unlocks after you submit in Step 3
Finish the manual in Step 1, pass the concept check, then submit your base project. Come back here for the two-player stretch.
Go to submit