0
⬇️

Gravity

Our bird is floating in mid-air. That is not how the real world works. Time to add gravity, the force that pulls everything down. This is what makes Flappy Bird feel real.

Gravity = Adding to Y

Remember: bigger Y means further down. So to make something fall, we keep adding to its Y position.

Each frame, we add a little to Y. The bird slides down the screen.
🍎

Newton would be proud

In the real world, gravity makes things fall faster over time. We simulate this with two variables: velocity (how fast the bird is moving) and gravity (how much velocity increases each frame).

The Two-Step Fall

Each frame, two things happen in order:

1

Gravity pulls on velocity

velocity += gravity (the bird speeds up)

2

Velocity moves the bird

bird_y += velocity (the bird’s position changes)

gravity logic
1gravity = 0.5
🌍 A small constant: how strong gravity is
2bird_velocity = 0
🏁 Starts at 0, the bird is not moving yet
3
4# Each frame:
5bird_velocity += gravity # speed up
📈 Velocity grows each frame (0, 0.5, 1.0, 1.5...)
6bird_y += bird_velocity # move down
📍 The bird falls faster and faster, just like real life

Quick Check

🧮

Think it through

Frame 1: velocity = 0 + 0.5 = 0.5
Frame 2: velocity = 0.5 + 0.5 = 1.0
Frame 3: velocity = 1.0 + 0.5 = ?

After 3 frames with gravity = 0.5, what is the bird’s velocity?

Your Turn: Make It Fall

Use the right operators to wire up gravity.

🍌

Velocity: 0.0

🎯
🎯

Level Goal

Make the bird fall by adding gravity to velocity, then velocity to bird_y.

Logic Lab: python.py
0/2
123456
gravity = 0.5 bird_velocity = 0 # Inside the game loop: bird_velocity gravity bird_y bird_velocity

Choose for blank #1