Skip to content

Latest commit

 

History

History
89 lines (68 loc) · 4.18 KB

File metadata and controls

89 lines (68 loc) · 4.18 KB

Game Programming Patterns

Worked examples from Robert Nystrom's Game Programming Patterns, implemented in C++ on top of Storm Engine v2.

Each pattern is a self-contained example under patterns/<category>/<name>/, with its own engine shell (Game + GameStateMachine + a PlayState), igloo specs, and README. Categories follow the book's structure.

The Patterns

Design Patterns Revisited — patterns/design/

Pattern Status Reference
Command chapter
Flyweight chapter
Observer chapter
Prototype chapter
Singleton chapter
State chapter

Sequencing Patterns — patterns/sequencing/

Pattern Status Reference
Double Buffer chapter
Game Loop chapter
Update Method chapter

Behavioral Patterns — patterns/behavioral/

Pattern Status Reference
Bytecode 🚧 planned chapter
Subclass Sandbox 🚧 planned chapter
Type Object 🚧 planned chapter

Decoupling Patterns — patterns/decoupling/

Pattern Status Reference
Component 🚧 planned chapter
Event Queue 🚧 planned chapter
Service Locator 🚧 planned chapter

Optimization Patterns — patterns/optimization/

Pattern Status Reference
Data Locality 🚧 planned chapter
Dirty Flag 🚧 planned chapter
Object Pool 🚧 planned chapter
Spatial Partition 🚧 planned chapter

Requirements

  • Storm Engine v2 installed (libstormenginev2 + stormengine2 headers)
  • SDL2, SDL2_image, SDL2_ttf, SDL2_mixer
  • igloo (header-only test framework)

Build, run, test

Each pattern builds independently from its own directory (binaries land in the repo-root bin/):

cd patterns/design/command
make            # builds the example
make run
make test       # builds the igloo specs
make run-test

Adding a new pattern

  1. Copy patterns/__template__/ to patterns/<category>/<name>/.
  2. In its Makefile, set NAME and make the include path point at the root common.mk (../../../common.mk for a <category>/<name> folder).
  3. Replace REPLACEME in src/game.cpp (window title) and the README (including its reference link).
  4. Implement the pattern in src/states/playState.cpp (and add classes under src/), with specs under specs/.
  5. Flip the pattern's status to ✅ above.

The shared build config lives in common.mk; it locates the repo root from its own path, so patterns work at any folder depth.