- Learnt27 min · the shark, the sea, four kinds of fish
- Basic25 min · build the whole game
- Challenge 1–327 min · your own version, animate it, two players
- Extrabonus · one fish you must not eat
Review — where we got to 5 min
Last lesson you learnt to make copies properly.
- The real sprite hides and makes clones. The clones run
when I start as a clone. - One number in a repeat decides how many there are.
delete this clonefinishes a clone off;hideonly makes it invisible.
Quick-fire
How many bats are on the Stage after this runs?
when flag clicked
repeat (6)
create clone of [myself v]
end
Reveal the answer
Seven. Six clones plus the real one, which nobody hid. That extra bat never flies and cannot be caught — and it is the first thing to check when a clone game behaves oddly.
Today’s Topic 3 min
- The Shark Game
- Flipping a costume so it faces the way the sprite does
- Several kinds of one thing, each with its own clones
Learning outcome
By the end of this lesson you will be able to:
- Build a complete game out of blocks you already know.
- Say why a costume that faces the wrong way makes direction blocks behave oddly.
- Fill a Stage with several kinds of moving thing using clones.
Learnt — the shark and the sea 27 min
The rules
| # | Rule | Where you learnt it |
|---|---|---|
| 1 | Arrow keys drive the shark; it starts in the middle. | Topic 1.6 |
| 2 | Space open the mouth; letting go closes it. | Topic 1.7 |
| 3 | Going right it faces right, going left it faces left. | Topic 1.7 |
| 4 | 12 to 20 fish, spawned randomly, moving randomly at a steady speed. | Topic 1.9 and 1.10 |
| 5 | A fish disappears only into an open mouth. | Topic 1.8 |
| 6 | At least four kinds of fish, in roughly equal numbers. | Topic 1.10 |
| 7 | Fish bounce off the edges. | Topic 1.9 |
The shark
Shark at 60%, fish at 30%. Two costumes: shark-swim with the mouth shut, shark-bite with it open.
How to use this: Click the green flag, then click the stage once and use the arrow keys to move the Shark. The space bar does something as well — find out what.
The fish
Four kinds. Each one is a sprite that hides itself and makes three or four clones, and each clone swims a random heading at a steady speed and bounces off the walls.
You have written this exact script before — it was the bat in Topic 1.10. The only thing that changes is which costume it wears.
when flag clicked
hide
repeat (4)
create clone of [myself v]
end
when I start as a clone
show
set size to (30) %
set rotation style [left-right v]
go to [random position v]
forever
point in direction (pick random (-180) to (180))
repeat (pick random (10) to (25))
move (3) steps
wait (0.05) seconds
end
end
Getting eaten
The fish checks two things, one inside the other: am I touching the shark, and is its mouth open? It cannot see the shark’s costume, so it reads the space key — Topic 1.8 again.
when I start as a clone
wait (0.5) seconds
forever
if <touching [Shark v]?> then
if <key [space v] pressed?> then
delete this clone
end
end
end
That is four stacks on one fish sprite: make the clones, swim, bounce, get eaten. Every one of them is doing a different job at the same time.
Basic — build the game 25 min
Build it in this order and test after every step. Do not skip the testing.
How to use this: Click the green flag, then click the stage once and use the arrow keys. The space bar does something as well — find out what.
Step 1 — the sea
New project. Backdrop Underwater 1. Delete the cat. Add your shark and set it to 60%.
Step 2 — the shark swims
Build the controller: rotation style left–right, go to (0, 0), the four movement ifs with facing in the left and right ones. Test all four keys.
Step 3 — the mouth
Add the if / else on key [space v] pressed? to switch between the two costumes. Hold space and let go a few times.
Step 4 — one fish
Add a fish sprite. Build its maker stack, its swimming stack and its bouncing stack. Press the flag: four fish, swimming about.
Step 5 — eating
Add the fourth stack. Test both ways: swim through a fish with the mouth shut, then again with it open.
Step 6 — three more kinds
Right-click the fish sprite and duplicate it three times. On each copy, change the costume and the number in the repeat.
Four sprites at 4, 4, 3 and 3 clones gives you fourteen fish. Keep the numbers within two of each other, as the rules ask.
Step 7 — play it
Clear the whole sea. Then press the flag again and check you get a fresh one. If any fish is left over from last time, a hide is missing from a maker stack.
My shark swims backwards.
The costume faces left. Open the Costumes tab and use Flip Horizontal on both of them. Do not try to fix it in the code.
Fish disappear when I swim past with my mouth shut.
Your delete this clone is inside the touching-if but outside the space-if. It needs to be inside both.
The same game, your world
Build a game that works like the Shark Game, but somewhere else entirely. A cat collecting food, a bird collecting seeds, a robot collecting bolts — your choice.
- At least four kinds of thing to collect.
- All of them moving randomly, all of them clones.
- One character you drive.
Animate it — but only when it moves
Give your character a walk cycle. The catch: it must animate only while it is actually going somewhere. Standing still, it stands still.
Then add a second player on W A S D.
Done when: your character’s legs move while a key is held and stop the moment it is let go, and you can drive both characters at once with two hands.Teacher reveal — animating only while moving
The neat answer puts next costume inside the movement ifs rather than in a stack of its own — so it only ever runs on a frame where a key was down:
if <key [right arrow v] pressed?> then
point in direction (90 v)
change x by (5)
next costume
end
It will animate very fast — one costume per frame. A wait (0.05) seconds would fix that but would also make the controls sluggish, which is a real trade-off worth discussing rather than solving.
Two hunters in one sea
Two players, both collecting from the same pool of things.
- Player 1 on W A S D with its own “collect” key.
- Player 2 on the arrow keys with its own.
- Either player can take any collectible.
- Both animate while moving.
Teacher note
The collectible now has two ways to be taken, so it needs two touching-checks in its forever, each paired with its own collect key. It is the same shape as Topic 1.8’s two-player challenge — and the obvious next question, “who got more?”, is exactly what next lesson is for.
One you must not eat
Add a fifth kind — a jellyfish, a bomb, something clearly different to look at — that you are not supposed to collect.
Touch it and something bad happens: your character shrinks, or slows down, or is sent back to the middle. Your choice, but it must be obvious.
Summary 5 min
- A whole game is not a new kind of thing. It is the parts you already know, built in order and tested one at a time.
- Flip a costume so it faces right. Scratch’s direction 90 means right, and a picture that disagrees makes every direction block confusing.
- Four kinds of one thing is four sprites, each cloning itself. The scripts are identical except for the costume.
- One fish sprite carries four stacks: make, swim, bounce, get eaten.
- Collectible
- Something in a game the player is meant to pick up.
- Hazard
- Something the player is meant to avoid.
- Flip Horizontal
- The paint editor button that mirrors a costume left to right.
Hand in
Share your project and send the link to your teacher. Keep this project safe — next lesson carries straight on from it.