Level 1Project 1 · Session 14
14

Project 1 · A game of your own · Build

Build it

What we are making: the thing itself, working end to end. Not finished — working.

Build it in this order

  1. Get the sprites on the screen and in the right starting places. Nothing moves yet.
  2. Make one thing move. Just one. Test it before adding anything else.
  3. Add the thing that happens when they touch — catching, hitting a wall, answering right.
  4. Add the score, or the ending. Last, not first.
  5. Now go back to the green flag and make sure everything resets properly when it is clicked again.
The shape almost every one of these ends up having
when green flag clicked
set score to 0
go to x: 0 y: -120
forever
if touching apple? then
change score by 1
📷
images/l1-p14-script-shape.png
Screenshot: that shape built in Scratch, on a working catching game
💡 Tip
Test after every single block you add. Click the green flag, watch, click the stop sign. It takes four seconds. If you add ten blocks and then test, you have ten places the problem could be; if you test after each one, you always know exactly what broke it.

The bug everybody gets

You play it once and it works. You click the green flag again and the score carries on from where it was, or the sprite is still where you left it.

That is because starting the game and setting things up are two different jobs. Every sprite needs its own when green flag clicked that puts it back where it belongs and resets anything that counts.

What you seeWhyWhat to do
The score keeps going up foreverThe forever loop has no pause.Add a short wait, or make the apple vanish and reappear after it is caught.
It works once, then not againNothing resets on the green flag.Give every sprite a green-flag script that sets its position and its variables.
The sprite goes off the edge and never comes backNo limit on the movement.Use if on edge, bounce, or check the x position before moving.
Two things happen at once and it looks wrongTwo scripts are both running.That is normal in Scratch. Decide which one should win and use a variable to stop the other.

Before you leave

  • Something that runs from the green flag to the end.
  • Your project saved with your name in the filename.
  • One thing you know is still wrong, written in your notebook.
Challenge optional — only if you finish early
  • Add sound. One for scoring, one for losing. Keep them short.
13. Choose it, and plan it