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.
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.
Red
Green
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.
# Inside the game loop, after screen.fill(): # Draw a yellow rectangle for the bird# Arguments: (surface, color, (x, y, width, height))pygame.draw.rect(screen, (255, 255, 0), (50, bird_y, 30, 30))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).