Make a Game 🎮
beginner20 XP

Arrow Keys & if

Drive a fish with arrow keys and make it react with if.

Arrow Keys & if 🐠

Games let you control a character. Let's swim a fish around the ocean!

Move with arrow keys

when [right arrow v] key pressed
point in direction (90)
move (10) steps

when [left arrow v] key pressed
point in direction (-90)
move (10) steps

Make it smart with if

An if block asks a question. If the answer is yes, it runs the blocks inside.

when flag clicked
forever
  if <touching (Jellyfish v)?> then
    say [Ouch! A jellyfish!] for (1) seconds
  end
end
💡

🧠 The pointy blocks like touching? are questions. They fit in the pointy hole of if.

🛠️ Build it!

  1. Pick the Fish sprite, a Jellyfish sprite and an underwater backdrop. 🌊
  2. Give the fish both arrow-key scripts.
  3. Give the fish the if touching script.
  4. Click the 🟢 flag and swim into the jellyfish!

⭐ Bonus: add up arrow and down arrow scripts too (use point in direction (0) for up and (180) for down).

🌊 Fun fact

Coral reefs are home to about 1 in 4 of all kinds of ocean fish, even though they cover a tiny part of the sea!

🛠️

Build it in Scratch!

Open Scratch in a new tab, find the blocks shown above (they're the same colors!), snap them together and click the green flag. Then try the challenge ideas in the lesson.

Open Scratch ↗

Scratch is free and made by MIT for kids. You can build without an account. To keep a project, ask a grown-up to help you sign in, or use File → Save to your computer.

Quick check

01/5
What does an if block do?