Stage 3: Ground and First Spikes
Stage 3: Ground and First Spikes
Keep your Scratch project tab open all week. Open in a new tab so you don’t leave the course.
a floor line, a spike obstacle, and crash detection
how touching detection creates danger
the first real fail condition
- Paint a Ground sprite as a long rectangle near the bottom of the stage.
- Paint a Spike sprite as a triangle and place it on the floor.
- Show the cube touching the spike and switching gameOn to 0.
- Add a short crash sound or color flash if students want one.
The big idea
A platformer needs safe space and danger space. The floor is safe. The spike is danger. Collision detection decides which one the cube is touching.
- collision
- when two sprites touch each other
- obstacle
- something the player must avoid
- hitbox
- the invisible touching area Scratch uses for a sprite
- fail state
- the game state after the player crashes
Stage 2 should be done. The cube can jump and land.
Students may follow these examples or draw their own versions in Scratch. Keep the sprite names from the lesson.
Follow the target shapes shown here so your scripts match the lesson quickly.
Draw a custom cube, spikes, portal, or backdrop in Scratch. Keep the same sprite names so the code still works.
The cube stays near the left side while the level scrolls toward it. Jump timing is the whole game.
Build it
- Paint a Ground sprite. A simple bright rectangle is enough.
- Paint a Spike sprite. Use a clean triangle with a thick outline.
- Place Spike at x: 120 y: -100 so it sits on the floor.
- Add the crash checker to the Cube sprite.
- Playtest by dragging the spike under the cube, then by jumping over it.
Crash checker
forever if <<touching [Spike v] ?> and <(gameOn) = (1)>> then set [gameOn v] to (0) say [Crash!] for (1) seconds end end
Understand it
The spike does not need to know it is dangerous. The Cube checks for touching and decides what happens. That keeps the player's rules in one place.
Try this
Try this
Three short experiments. Predict before you run, then test your guess.
Test your stage
- Ground is visible near the bottom of the stage.
- Spike is named Spike exactly.
- Touching Spike sets gameOn to 0.
- A clean jump can clear the spike.
If it breaks
- If crashes never happen, check the sprite name in the touching dropdown.
- If crashes happen too early, edit the costume so empty transparent space is removed.
Keep students moving on the default path first. Custom assets are encouraged, but the required names and variables are not optional. If debugging takes more than a few minutes, compare the student's sprite names, variable names, and block order against the stage test list.