Skip to main content

Stage 5: Spawn Patterns

Stage 5: Spawn Patterns

Course progressStage 5 of 10
~90 min
Your workspace

Keep your Scratch project tab open all week. Open in a new tab so you don’t leave the course.

Build

cloned spike patterns

Learn

how one template sprite can create many obstacles

Ship

a level that keeps producing jumps

Teacher demo
  1. Hide the original Spike template.
  2. Create clones on a timed loop.
  3. Each clone starts on the right, moves left, then deletes itself.
  4. Change one random number to make gaps less predictable.

The big idea

Clones let one Spike sprite become a whole level. The template holds the costume and scripts; each clone becomes one obstacle run.

New words
clone
a temporary copy of a sprite made while the project runs
template
the original sprite used to create clones
pattern
a repeated obstacle idea
random
letting Scratch choose a value inside a range
Before you start

Stage 4 should be done. One scrolling spike works.

Use the examples

Follow the target shapes shown here so your scripts match the lesson quickly.

Make your own

Draw a custom cube, spikes, portal, or backdrop in Scratch. Keep the same sprite names so the code still works.

Finished game target
Cube runnerSpike obstacle

The cube stays near the left side while the level scrolls toward it. Jump timing is the whole game.

Build it

  1. Click the Spike sprite and keep its costume.
  2. Replace the single-spike scroll with a clone spawner.
  3. Use create clone of myself every 1.4 seconds while gameOn is 1.
  4. Put movement code inside when I start as a clone.
  5. Delete clones when they leave the left edge or when the game stops.

Spike clone spawner

when green flag clicked
hide
forever
if <(gameOn) = (1)> then
create clone of [myself v]
wait (1.4) seconds
end
end

when I start as a clone
go to x: (260) y: (-100)
show
repeat until <<(x position) < (-260)> or <(gameOn) = (0)>>
change x by (-6)
end
delete this clone

Understand it

The template is hidden, but clones show themselves. That pattern prevents the original sprite from sitting on the stage and causing surprise crashes.

Try this

Learning beat

Try this

Three short experiments. Predict before you run, then test your guess.

Predict first
Change wait 1.4 to wait 0.8. Predict how the level changes.
Compare
Try speed -5 and -8. Which one works better with your jump height?
Connect
Stage 6 adds score. What action should increase the score: time alive, spikes passed, or both?

Test your stage

  • The original Spike is hidden when the game starts.
  • Spike clones appear on the right.
  • Each clone moves left and deletes itself.
  • Crash detection still works when touching a clone.

If it breaks

  • If too many clones pile up, check delete this clone.
  • If the original spike is visible, add hide under green flag.
Coach notes

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.