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

Science project idea

Scratch flying-bird game with gravity and moving pipes

A speed variable that keeps decreasing acts like gravity, and a key press resets it upward. It teaches how simple rules about speed produce natural-looking motion.

What it shows

A speed variable that keeps decreasing acts like gravity, and a key press resets it upward. It teaches how simple rules about speed produce natural-looking motion.

The science

Gravity pulls things down faster and faster. In the program a variable called speed goes down by 1 each loop, and the bird’s y position changes by speed, so it falls faster over time. Pressing the space bar sets speed to a positive number, which pushes the bird up, then gravity takes over again. Collision is checked with the touching block.

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)
  • A Parrot or Bird sprite and a pipe drawn as a green rectangle in the Paint Editor
  • A notebook and a pencil

Safety

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. Make variables for all sprites: speed and score. Draw a green rectangle sprite called Pipe with the Rectangle tool.

  2. On the Bird: when green flag clicked, go to x: -100 y: 0, set speed to 0, set score to 0.

  3. Add forever with change speed by -1, then change y by (speed).

  4. Inside the forever add if key space pressed? then set speed to 8.

  5. Add another if inside it: if touching Pipe? then say Game over for 2 seconds and stop all. Also stop if y position < -170.

  6. On the Pipe: when green flag clicked, go to x: 240 y: (pick random -100 to 100), then forever with change x by -4.

  7. Inside the Pipe forever add if x position < -240 then go to x: 240 y: (pick random -100 to 100) and change score by 1.

  8. Play and adjust: if the bird falls too fast change -1 to -0.5; if the jump is too high change 8 to 6.

What you should see

The bird falls under gravity and jumps when space is pressed. Pipes scroll left at random heights, the score rises as each pipe passes and the game stops when the bird touches a pipe or the ground.

Viva questions

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

1How does speed copy gravity?

It decreases every loop, so downward motion gets faster, as in free fall.

2What does the space bar do?

It sets speed to a positive number, giving the bird an upward push.

3Why change y by speed and not by a fixed number?

So the movement depends on speed, which changes each loop.

4How is the score counted?

Each time a pipe returns to the right edge, one pipe has been passed.

Free ebook: Viva Questions for Science Projects

Take it further

Make two pipes, one at the top and one at the bottom, with a gap between them, and speed them up after every five points.

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

WhatsApp us