The hub for proven patterns discovered during development. The working principles below apply everywhere; each concrete pattern lives in one of five cluster pages — open the one your work touches, not all five.
| Cluster | Patterns |
|---|---|
| patterns/rendering.md | Coordinate Conversion · 2D Rotation with Matrix · Y-Sorted Draw Order · Drop-In Draw Wrapper · HUD Zone Width Discipline |
| patterns/movement.md | Thrust & Momentum · Fixed-Timestep Accumulator · Always-On Metrics · Walkability-Oracle Navigation · One Movement Primitive |
| patterns/entities.md | Base Class for Reusable Entity Logic · Compose Don’t Inherit · Role → Routine Registry |
| patterns/ui-screens.md | Scrollable Menu List · Scrollable List Handler · 2D Grid Sibling · Screen State Machine · Config-Driven Screen Dispatch · Menu vs. Dialog |
| patterns/persistence.md | State Persistence (get_state/restore_state) · Data-Driven Configuration |
When a behavior needs to apply everywhere (window close, event filtering, startup logic), handle it once in the main loop or a base class, not repeated in every subclass.
pygame.QUIT is handled in the main event loop, so any new
screen works without modification.When you notice the same pattern appearing in multiple places:
_handle_scrolling_input()).get_state() on
ScreenBase).When implementing a feature or fix, watch for a clever solution other code could reuse, or repeated logic that wants extracting, and raise it.
When you discover a reusable solution:
Example: When fixing a bug or implementing a feature, if you notice:
…document it as a pattern so future code can reuse the solution.