Skip to main content

Stage 5: Create the Enemy Fish

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

a new sprite with two costumes, a Chomp sound, and three variables

Learn

how to set up a sprite that will be a template for many clones

Ship

an Enemy Fish ready to spawn an entire swarm in Stage 6

Teacher demo

Show the room. The book breaks this into 6 steps — walk through each:

  1. Choose a SpriteFish (from Animals). A new sprite appears in the sprite pane.
  2. Click the Costumes tab. Delete fish-a and fish-d. Keep fish-b and fish-c.
  3. Sounds tab → Choose a SoundChomp.
  4. VariablesMake a Variable → name it enemySize. For this sprite only. (Different from the Player's For-all-sprites choice — point at the radio button.)
  5. Make a Variable twice more: fishEaten and score. Both For all sprites. Check the boxes to show them on the stage.
  6. On the stage, right-click fishEaten and score variable readouts → large readout.

That's the whole setup. No code yet. The enemy fish is just a template.

The big idea

Today we meet the Enemy Fish.

The Enemy Fish is different from the Player Fish in one important way: the Player Fish is just one fish on screen. The Enemy Fish is a template — a sprite that gets cloned many times. The fish itself never appears in the game. Only its clones do. (We do the cloning in Stage 6.)

Because we'll be making lots of clones, each one needs its own properties — its own size, its own costume, its own direction. To make that work, we need a Scratch trick called variable scope. Some variables belong to the whole game (we can read them from any sprite). Some variables belong to just one sprite — and each clone gets its own copy.

Variables For All Sprites Variables For This Sprite Only
- playerAlive - enemySize
- playerSize (each clone has its OWN copy)
- fishEaten
- score

That For this sprite only option is the new Scratch concept of the day.

We also add two new game-wide stats: fishEaten (how many enemies the player has eaten) and score (the player's running score). We show these on the stage so the player sees their progress as they play.

New words
template sprite
a sprite that will be cloned, not used directly
clone
a copy of a sprite that runs the same scripts independently
For this sprite only
a variable scope where each sprite (and each clone) gets its own copy
For all sprites
a variable scope where all sprites share one value
readout
the visible display of a variable on the stage
large readout
a bigger, easier-to-read display style for a variable
Before you start

Stages 1–4 should be done — your Player Fish has setup, movement, growth, and win/lose handlers.

Build it

Step 1 — Add a new Fish sprite

In the sprite pane (bottom-right), hover over the cat-face Choose a Sprite button. A menu pops up. Click Choose a Sprite (the cat icon).

A library opens. Click the Animals category. Find Fish (note: this is Fish, not Fish-a) — it's a sprite that comes with multiple fish costumes built in. Click it.

A new sprite appears in the sprite pane. By default it's named Fish. Leave the name — we'll use it as-is.

sprite

Fish

This is the enemy template sprite. It will hide itself in Stage 6, then create clones that swim across the stage.

Step 2 — Delete fish-a and fish-d, keep fish-b and fish-c

The Fish sprite comes with four costumes: fish-a, fish-b, fish-c, fish-d. We only want fish-b (yellow striped) and fish-c (purple) for our enemies — the others look too similar to the Player Fish.

Click the Costumes tab. In the costumes list:

  • Click the × on fish-a to delete it.
  • Click the × on fish-d to delete it.

You should now see only fish-b and fish-c in the list.

Step 3 — Add the Chomp sound

Click the Sounds tab. The Fish sprite comes with two sounds already (Bubbles and the underwater ambient one), but we want to add a Chomp sound for when the player eats this fish.

Click Choose a Sound. Find Chomp (a chewing/biting sound). Click it.

The Chomp sound is added. We'll trigger it in Stage 8 when the player chomps this enemy.

sound

Chomp

Add this sound to the Fish sprite, not the Player sprite. The collision script in Stage 8 runs on the Fish clones.

Step 4 — Make the enemySize variable (For this sprite only)

This is the new concept of the day.

In the block palette, click Variables. Click Make a Variable.

A pop-up appears. Now this is the important part:

  • Name: enemySize
  • Choose For this sprite only (NOT For all sprites).
  • Click OK.

Why "For this sprite only"? Because each clone of the Enemy Fish needs its own size. Some clones will be small (the player can eat them). Some will be big (they can eat the player). If enemySize were For all sprites, every clone would share one size — completely breaking the game.

For this sprite only means: every clone gets its own copy of enemySize. Clone 1 might be size 50; clone 2 might be size 200. Their sizes don't talk to each other.

Step 5 — Make fishEaten and score variables (For all sprites)

These two variables are game-wide. They track the player's progress across the whole game.

Click Make a Variable. Name it fishEaten. Choose For all sprites. Click OK. Check the box next to fishEaten in the palette so it shows on the stage.

Click Make a Variable again. Name it score. Choose For all sprites. Click OK. Check the box next to score in the palette so it shows on the stage.

Now you should see two new readouts on the stage:

fishEaten: 0
score: 0

Both at the top-left by default. You can drag them around the stage to wherever you want.

Step 6 — Set fishEaten and score to large readout

The default readouts are small and clunky. We make them bigger so the player can see them clearly.

On the stage, find the fishEaten readout. Right-click it (or Ctrl-click on a Mac). A menu pops up. Choose large readout.

The readout becomes much bigger — just a number, no label.

Do the same with score: right-click → large readout.

Save your project.

Understand it

The new idea today is variable scope, and it's the most important Scratch concept for any game with multiple sprites or clones.

Think of variables like lunchboxes. A variable that's For all sprites is the cafeteria's shared snack table — everyone reads from and writes to the same table. There's only one. A variable that's For this sprite only is your own lunchbox — every sprite (and every clone) has its own private one. Your lunchbox can hold a sandwich while your friend's holds an apple. They don't interfere.

enemySize is For this sprite only because each clone needs its own. If a small clone has enemySize = 50 and a big clone has enemySize = 200, both sizes need to exist at the same time. Sharing one variable would mean every clone is the same size.

fishEaten and score are For all sprites because they're game-wide. The Player sprite needs to change them when it eats an enemy (Stage 8). Stage 10's stats screen needs to read them. Cross-sprite communication only works with For-all-sprites variables.

The Fish sprite library has multiple costumes so we can give clones visual variety. Stage 7 will pick randomly between fish-b and fish-c when spawning each clone — the swarm looks varied instead of identical. We deleted fish-a (orange — too similar to Player) and fish-d (a less interesting design) to keep the visual story clean.

The large readout style for fishEaten and score is a small design choice with a big impact. Default readouts include a label ("fishEaten: 5"); large readouts just show the number. By the time we have these on the stage during gameplay, the player sees a clean number going up — not a sentence to parse.

Try this

Learning beat

Try this

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

Predict first

Imagine enemySize were For all sprites instead. Predict what would happen when 10 clones exist and each tries to be a different size. Why does this matter for the game?

Compare

Right-click fishEaten on the stage and choose normal readout instead of large. Compare to large. Which one is easier to read at a glance while you're playing? Large readouts are a gameplay choice.

Connect

Stage 6 spawns the clones. Stage 7 makes each clone pick its own random size (using set enemySize to (random)). Look at the variable scope of enemySize. Does that random choice belong to one clone, or to all of them?

Test your stage

  • Your project has two sprites in the sprite pane: Player and Fish.
  • The Fish sprite has exactly two costumes: fish-b and fish-c.
  • The Fish sprite has at least Chomp in its Sounds tab.
  • You have three new variables: enemySize (For this sprite only), fishEaten (For all sprites), score (For all sprites).
  • fishEaten and score both appear on the stage as large readouts.
  • Both start at 0 when the green flag is clicked. (Tip: add set fishEaten to 0 and set score to 0 to your Player's setup chain if needed. We'll move them to a better home in Stage 10.)
  • Your project is saved.
  • Design check. Click the green flag. Are the fishEaten and score readouts in spots where they don't overlap with the fish or the game area? Drag them to good spots — top-left works.

If it breaks

  • I can't find the Fish sprite in the library. Make sure you clicked the Animals category. Search for "fish" if needed. The icon you want has multiple stripey fish in it.
  • enemySize is sharing values across clones in Stage 6. You picked For all sprites by mistake. Variables can't be changed from one scope to another — you'll need to delete enemySize (right-click it in the palette) and create it fresh as For this sprite only.
  • fishEaten and score don't show on the stage. Check the box next to them in the Variables palette. (Or drag them out of the palette onto the stage.)
  • Large readout doesn't appear in the right-click menu. Right-click on the readout itself (the number on the stage), not on the variable in the palette. The menu is different in those two places.
  • I accidentally deleted fish-b or fish-c. Click Choose a Costume, search for "fish," and add them back from the Animals category.
Coach notes

This stage is structurally simple but introduces variable scope, which is conceptually the hardest Scratch idea kids 7–9 will hit. Move slowly through Step 4.

The single most common failure: making enemySize as For all sprites. The game won't work in Stage 8 — every clone will be the same size, and the player can never grow because every enemy reads the same enemySize. Walk the room after Step 4 and confirm the radio button on each laptop.

The second most common: not checking the boxes next to fishEaten and score so they show on the stage. Without the checks, the readouts never appear and Stage 10's stats screen has nothing to display.

The "large readout" right-click menu is unfamiliar — kids try right-clicking the variable in the palette, which gives a different menu. Specifically demo right-clicking on the stage readout itself during the teacher demo.

If a camper accidentally renames the Fish sprite to something else (it should stay as just Fish), Stage 8's collision detection will fail because the Player's code references touching (Fish) — a literal sprite name lookup. Walk the room and confirm naming.

If a camper finishes early, push them into the medium stretch (color tuning). The hard stretch (third costume) primes them for Stage 7 — solid prep but optional.