Lesson 5: Pygame Setup + First Window (Matthes Ch 12 ยง1-3)
Learning Intentions
- Install Pygame, open a game window, understand the event-poll game loop pattern.
Success Criteria
- Pygame installed on my laptop.
- My alien_invasion.py opens a navy-coloured window.
- The window closes cleanly when I click X.
๐ Do Now โ Error of the Day
Type pip --version in your terminal. What comes up? (This checks if pip is installed โ it comes free with Python.)
๐ I Do โ Teacher Demo
Live-install pygame (pip install pygame), then live-code the minimal 20-line Pygame skeleton: init, display.set_mode, event loop, fill, flip. Explain what each line does.
๐ค We Do โ Build Together
Class types along โ everyone gets a Pygame window open. Verify: raise hand if your window opens. We troubleshoot install issues 1-on-1.
๐ You Do โ Your Turn
Customise your window: size, background colour, title bar text. Try 3 different colour schemes. Arcade quests below cover event loop basics.
- pip install pygame (troubleshoot 1:1)
- Type the minimal Pygame skeleton from scratch
- Change window size + background colour
- Understand what each of pygame.init(), display.set_mode, event.get, display.flip does
๐ฎ Practice Quests โ work through these
Loading practice quests for this lesson...
Three tiers โ pick yours
Support
alien_invasion_starter.py with skeleton pre-typed. 1:1 install help
Core
type skeleton from scratch
Extension
Settings class refactor
Extensions
- Build a Settings class holding screen_width, screen_height, bg_color (preview of L07).
- Change title bar text dynamically (e.g. show frame count).
๐ Exit Ticket โ Coding Journal
Journal: what's one thing about Pygame that feels different from regular Python you've done?
Evidence of Learning
Each student has a running Pygame window with custom size and colour.