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.
| Pattern | Status | Reference |
|---|---|---|
| Command | ✅ | chapter |
| Flyweight | ✅ | chapter |
| Observer | ✅ | chapter |
| Prototype | ✅ | chapter |
| Singleton | ✅ | chapter |
| State | ✅ | chapter |
| Pattern | Status | Reference |
|---|---|---|
| Double Buffer | ✅ | chapter |
| Game Loop | ✅ | chapter |
| Update Method | ✅ | chapter |
| Pattern | Status | Reference |
|---|---|---|
| Bytecode | ✅ | chapter |
| Subclass Sandbox | ✅ | chapter |
| Type Object | ✅ | chapter |
| Pattern | Status | Reference |
|---|---|---|
| Component | ✅ | chapter |
| Event Queue | ✅ | chapter |
| Service Locator | ✅ | chapter |
| Pattern | Status | Reference |
|---|---|---|
| Data Locality | ✅ | chapter |
| Dirty Flag | ✅ | chapter |
| Object Pool | ✅ | chapter |
| Spatial Partition | ✅ | chapter |
-
Storm Engine v2 — nothing to install. It is a submodule at
external/storm-engine-v2, pinned to the revision these examples are written against, and the build compiles it from there. Clone with submodules:git clone --recurse-submodules <this repo>
Already cloned without them?
make enginefetches and builds the pinned revision. Nothing is installed system-wide, and the build deliberately has no "use the system engine instead" path — that is how a local build and CI came to run different engines (2.3.0 here, 2.3.1 in CI) without either saying so. -
SDL2, SDL2_image, SDL2_ttf, SDL2_mixer
-
igloo (header-only test framework)
The submodule pins a commit, so a build is reproducible until someone moves it on purpose:
make engine-update # advance the pin to the engine's newest main, and rebuild
make engine-version # which revision is pinnedAn automatic "always newest" was rejected: a red build should be traceable to a commit in this repo, not to one that landed in the engine five minutes ago.
The font the demos draw with is shared (include/pixelFont.h + its SDL
drawer), and its spec lives in patterns/__shared__/ — that folder is not a
pattern; __template__ is the one to copy.
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- Copy
patterns/__template__/topatterns/<category>/<name>/. - In its
Makefile, setNAMEand make theincludepath point at the rootcommon.mk(../../../common.mkfor a<category>/<name>folder). - Replace
REPLACEMEinsrc/game.cpp(window title) and the README (including its reference link). - Implement the pattern in
src/states/playState.cpp(and add classes undersrc/), with specs underspecs/. - 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. It builds against
the pinned engine via engine.mk, and force-includes
include/engineGlobal.h — a bridge that puts the
engine's namespace storm names back in the global scope so the pattern code
reads GameState rather than storm::GameState.