Head office, Rana Pratap Bagh, Delhi011 2721 1512+91 97116 99511

Science project idea

Scratch game: catch the falling fruit with a bowl

Variables keep score and lives, and a forever loop with an if block checks again and again whether the fruit touched the bowl. This is the core idea of every simple video game.

Make it yourself: 8 stepsGet a ready-made kit: Robotics and Coding

A drawing for computing and coding projects, not a photograph of this model.

What it shows

Variables keep score and lives, and a forever loop with an if block checks again and again whether the fruit touched the bowl. This is the core idea of every simple video game.

The science

A program is a list of instructions the computer follows in order. A forever loop repeats its blocks as fast as it can, so the game keeps checking the position of the apple. A variable is a named box that stores a number, so score and lives can be changed and displayed. An if block runs its blocks only when a condition such as touching Bowl is true.

Materials

Cost: free. Many items come from home or from waste; spare parts such as LEDs, motors and wire are in the store.

  • A computer, laptop or phone with a browser (free)
  • Scratch 3 in the browser at scratch.mit.edu (free, no sign-in needed to code)
  • Sprites from the Scratch library: a Bowl (or Basket) and an Apple
  • A notebook and a pencil

Safety

Read before you start

This project uses safe, everyday materials. Still, read the rules below with a parent before you start.

Never use mains electricity: power models with cells, batteries or a low-voltage adapter. Sharp and hot tools, flames and lab chemicals need an adult or your teacher beside you. Keep magnets, button cells and small parts away from young children, and wash your hands after making.

All the safety rules

Step by step

8 steps. Do them in order, and test each part before you go on to the next. Write what you notice in a notebook as you go.

  1. Open Scratch, click Create, and choose the Bowl sprite and the Apple sprite from the Choose a Sprite button.

  2. In Variables click Make a Variable, name it score, and make another called lives; both are for all sprites.

  3. Click the Bowl and build: when green flag clicked, forever, set x to (mouse x). The bowl now follows the mouse sideways.

  4. Click the Apple and build: when green flag clicked, set score to 0, set lives to 3, go to x: 0 y: 170.

  5. Under that add a forever loop containing change y by -6, so the apple falls.

  6. Inside the forever add an if touching Bowl? then block with change score by 1 and go to x: (pick random -200 to 200) y: 170.

  7. Add a second if block: if y position < -170 then change lives by -1 and go to x: (pick random -200 to 200) y: 170.

  8. Add a third if block: if lives = 0 then say Game over for 2 seconds and stop all. Click the green flag and play.

What you should see

Expected result

Fruit falls from a random place at the top. Your bowl follows the mouse, the score goes up for every catch and the lives drop for every miss. After three misses the game says Game over and stops.

Viva questions

A teacher or a judge will ask how it works. Try to answer each question before you open it, then compare.

01What does a variable do?

It stores a value, such as the score, that the program can change and show.

02Why is the check inside a forever loop?

So the computer tests for a catch or a miss again and again while the apple moves.

03What does pick random do?

It chooses a different number each time, so the apple starts at a new place.

04How can you make the game harder?

Change y by a bigger number so the fruit falls faster.

Free ebook: Viva Questions for Science Projects

Take it further

Make it your own

Add a second sprite, a rotten fruit, that takes away a life if the bowl touches it, and let the fall speed grow as the score rises.

Change one thing, measure what happens, and add a table or chart of your readings: that is what turns a model into your own investigation.

Free ebooks for this project

Find out more about computing and coding

Free, well-known places to explore the subject further. Ask a grown-up before you sign up for anything or type your name anywhere.

WhatsApp us