Ibnovate Course 1 · The Young Builders
⏱ 60 minLive session

Session 16 — Score & Loops

Duration: 60 min · Format: live online

What you'll learn: by the end, you can create a score variable, use a forever loop to keep the game alive, and use broadcasts so sprites can talk to each other.

Soft skill focus — Critical thinking

Today you'll also grow Critical thinking. Good makers test their guesses instead of assuming — like whether set or change is the right block for a growing score.

Try this: before you run your score code, predict what will happen if you use set Score to 1 on every press. Then run it, watch it stick at 1, and compare to your guess. A "wrong" prediction is the most useful kind — it teaches you something.

Think about: What did you predict set would do, and what actually happened?

What you'll need


Hook

Think about these questions:

Here's the big idea: today you learn three superpowers — a variable to remember the score, a loop to keep the game running forever, and a broadcast so your sprites can send each other messages.


Teach — Variables hold a number

Here's how variables work:

Build this in Scratch:

⚠ Watch for the mix-up between set and change: set Score to 0 replaces the number; change Score by 1 adds to it. If you use set Score to 1 every press, the score gets stuck at 1. Try it once so you can see the difference.

Quick question: at the start of a game, should you set Score to 0 or change Score by 0? Why? (Answer: set to 0 — you want it to become zero, not just add nothing.)


Teach — Forever loops and broadcasts

A game never stops checking things — it does the same job over and over. That's a loop. The forever block (yellow, Control) repeats everything inside it, endlessly.

Use this diagram to picture the game loop — when the flag is clicked, a forever loop keeps moving sprites, checking collisions, and updating the score:

Diagram of a game loop: a green-flag start leads into a forever loop drawn as a circular arrow, and inside the loop three repeating steps run over and over — move the sprites, check for collisions, and update the score

Build this in Scratch:

Now try broadcasts — how sprites talk to each other:

Key idea: a variable remembers, a loop repeats, and a broadcast lets sprites send messages to each other.

Try it: if you take the change y by -5 out of the forever loop and just leave it on its own, how many times does the apple move? (Answer: once.)


Activity

Now build your own "catch" starter.

Build this, step by step:

  1. Make a variable called Score (Variables → Make a Variable).
  2. On the main sprite: when green flag clickedset [Score] to 0.
  3. Add a second sprite (apple, ball, star).
  4. On the second sprite: when green flag clickedforeverchange y by -5.
  5. Inside the same forever loop, add if y < -150 thenset y to 150 (so it loops back to the top). If if/then is new, just use set y to 150 after a few seconds for now.
  6. On the main sprite: when [space] key pressedchange [Score] by 1 and broadcast [caught].
  7. On the second sprite: when I receive [caught]go to x: 0 y: 150 and play sound [Pop].
  8. Click the green flag and test: the apple falls, space adds to the score and resets the apple.

If something's not working, check:

Tip: change the falling speed (change y by -5-8) and notice the game gets harder.


Check yourself

Try these — answers are after the arrow.

  1. What is a variable, and what would you use one for in a game? → A box that remembers a number; use it for a score, a timer, lives, or a level number.
  2. What does a forever loop do? → It repeats the blocks inside it endlessly, so the game keeps checking or moving without stopping.
  3. How can one sprite tell another sprite that something happened? → With a broadcast — one sprite broadcasts a message, another runs when I receive that message.

Wrap-up


Tips & extra challenges

Vocabulary

Term Meaning
Variable A box that remembers a number, like a score
Set Put an exact value into a variable (replaces it)
Change Add to (or subtract from) a variable
Loop Blocks that repeat; forever repeats endlessly
Broadcast A message one sprite sends and others can receive

Resources

Practice set

Practise on your own. Answers are after the arrow.

  1. Make a variable called Score and set it to 0 when the green flag is clicked. → Variables → Make a Variable → name it Score; then when green flag clickedset [Score] to 0.
  2. Make the score go up by 1 every time you press the space bar.when [space] key pressedchange [Score] by 1. (Use change, not set.)
  3. Make a sprite fall down the screen forever.when green flag clickedforeverchange y by -5.
  4. When the falling sprite reaches the bottom, send it back to the top. → Inside the loop: if y < -150 thenset y to 150 (or go to x: 0 y: 150).
  5. Make one sprite send a message and another sprite react to it. → Sprite A: broadcast [caught]. Sprite B: when I receive [caught] → do something (play a sound, hide, reset position).
  6. Add a second variable called Lives, start it at 3, and lower it by 1 on a key press. → Make Lives; set [Lives] to 3 at start; when [key] pressedchange [Lives] by -1.

Going deeper (optional)

Common mistakes & fixes

If it's not working, check these common mix-ups:

What's next

Session 17 — Levels & Challenge: you'll add if/then decisions, detect when sprites are touching, and build real win and lose conditions to make the game harder.

Ibnovate · Build · Innovate
Type to search · Esc to close
Welcome back
Sign in to continue building.
Accounts are created by Ibnovate — ask your instructor for your login.
🔒