Game Programming Patterns
A well-loved book by Robert Nystrom, a former Electronic Arts engineer, on the design patterns that keep game code clean and fast: game loop, update method, command, observer, state, component, event queue, object pool, spatial partition and more. The full book is free to read on the web.
Book
Other
Robert Nystrom
Intermediate
Free
What it is
Game Programming Patterns is a book by Robert Nystrom, who also wrote Crafting Interpreters. It collects patterns he found in games that make code cleaner, easier to change and faster. The web edition is free and complete: the author states every format has the same content. Print, ebook and PDF editions are sold for those who want them.
Chapters are grouped as:
- Design patterns revisited: Command, Flyweight, Observer, Prototype, Singleton, State.
- Sequencing patterns: Double Buffer, Game Loop, Update Method.
- Behavioural patterns: Bytecode, Subclass Sandbox, Type Object.
- Decoupling patterns: Component, Event Queue, Service Locator.
- Optimisation patterns: Data Locality, Dirty Flag, Object Pool, Spatial Partition.
Is it worth reading?
Yes, once you have made a game or two and felt your code turn into a tangle. It explains why the engine you use works the way it does (the game loop and update method are what Unity, Godot and Unreal already do for you), and when a pattern such as State, Observer or Object Pool will make your own code simpler. It is funny and clear, and it warns when a pattern is overused, especially Singleton.
Examples are in simple C++, but the ideas apply directly to C# and GDScript.
Time and prerequisites
About 20 chapters that each take under an hour. Read the Game Loop, Update Method, State, Observer, Component and Object Pool chapters first. Basic object-oriented programming is enough.
Free vs paid
Free on the web. Paid print and ebook editions are available through the links on the site.
What you can do after it
Recognise and use the patterns that keep gameplay code manageable, and explain your design choices in a code review or a studio technical round.
Common questions
Is it outdated? No. Patterns change slowly, and the reasoning holds for modern engines.
Do I need C++? No. The C++ is simple enough to read with any C-style language background.
Where it fits in the Sefism roadmap
The Game Loop chapter is a read pick in the foundation stage, and the whole book is the deeper pick in the programming and engine stages.
Ready to start?
Opens on Robert Nystrom in a new tab.
Stuck on something specific?
Writing only gets you so far. If you want an answer to your situation rather than the general case, book a session and we will work through it together. Sessions are free for approved Sefism members, and a few slots open each week.
Follow along
New writing, resources and project ideas land here first.