📝 Worksheet← Lesson← Course
BitWithBite
Pygame Mastery · Quick Reference

Game Architecture Cheat Sheet

Pygame Mastery
In one line: A Scene/SceneManager pattern keeps Menu, Play and GameOver screens cleanly separated, backed by centralized asset loading and config constants.

Key Ideas

1Game States. Named modes (menu, playing, paused, game_over) that determine what updates and draws each frame.
2Scene Class. A base class with handle_events(), update(dt), draw(screen) — every screen (Menu, Play, GameOver) subclasses it.
3SceneManager. Holds the current Scene and swaps it out when a scene requests a transition (e.g. Play → GameOver).
4Asset Loading Helper. One centralized function/module loads and caches every image/sound, used everywhere instead of scattered load calls.
5Config Module. A config.py holding constants (SCREEN_WIDTH, FPS, colors) so magic numbers aren't repeated across files.

Scene Pattern

class Scene:
  def handle_events(self, events): pass
  def update(self, dt): pass
  def draw(self, screen): pass
class SceneManager:
  def __init__(self, start):
    self.scene = start
  def switch_to(self, new_scene):
    self.scene = new_scene
Game LoopSceneManagerScenes (Menu / Play / GameOver)Assets
Each layer only talks to the one below it — the loop drives the manager, the manager swaps scenes, scenes pull from shared assets.