0

Drawing the Bird

We have a window. Now we need someone to star in our game. In game development, every character and object on screen is called a sprite. Our sprite is a little yellow bird, and it starts as a simple rectangle.

Sprites: The Building Blocks

Every object in a game (the player, enemies, coins) is a sprite.

Our bird is just a yellow rectangle at position (50, 300).
🎭

Sprites are just shapes (for now)

Real games use images for sprites, but we will start with a colored rectangle. To place it on screen, we need four numbers: X position, Y position, width, and height.

Painting with Numbers

Computers make colors by mixing Red, Green, and Blue light. Each goes from 0 to 255.

(255, 0, 0)

Red

(0, 255, 0)

Green

(0, 0, 255)

Blue

🎨

Mix them up

(255, 255, 0) = Yellow (Red + Green). (0, 0, 0) = Black (no light). (255, 255, 255) = White (all light). Our bird will be bright yellow.

Which RGB value makes yellow?

Drawing on Screen

Pygame gives us pygame.draw.rect() to draw rectangles.

drawing the bird
1# Inside the game loop, after screen.fill():
2
3# Draw a yellow rectangle for the bird
4# Arguments: (surface, color, (x, y, width, height))
📐 surface = where to draw, color = RGB tuple, then a rectangle (x, y, w, h)
5pygame.draw.rect(screen, (255, 255, 0), (50, bird_y, 30, 30))
🐤 A 30x30 yellow square at X=50, Y=bird_y

Your Turn: Place the Bird

Set the bird’s starting position: near the left edge, vertically centered.

🎯
🎯

Level Goal

Place the bird at X=50 (near the left) and Y=300 (middle of the 600px screen).

Logic Lab: python.py
0/2
123456
# Bird starting position bird_x = bird_y = # Draw the bird (inside game loop) pygame.draw.rect(screen, (255, 255, 0), (bird_x, bird_y, 30, 30))

Choose for blank #1