This repository contains practical implementations of Design Patterns for game development, inspired by the book Game Programming Patterns by Robert Nystrom.
Each pattern is accompanied by:
- ๐ A theoretical explanation from the book
- ๐ฎ Examples of use in video games
- ๐ป Practical implementations in C++ (with some legacy JavaScript examples being migrated)
The repository is organized into several sections:
Includes clear explanations of each design pattern, along with references to how theyโre used in real games.
Example:
command/
pattern
- Contains a
README.md
with the Command Pattern theory and use cases
Modern implementations of the patterns in C++, ideal for performance-sensitive and low-level control use cases in game development.
- Visual implementations use Raylib, a simple and easy-to-use game programming library in C.
- Each pattern is isolated in its own subfolder.
- Contains original implementations in JavaScript.
- These are gradually being ported to C++ (in
src/
), prioritizing patterns that benefit more from low-level handling.
Legend | Meaning |
---|---|
โ | Implemented |
๐ง | Work In Progress |
Design Patterns: Elements of Reusable Object-Oriented Software
Revisited by Robert Nystrom
Pattern | C++ (src/ ) |
JS (javascript/ ) |
---|---|---|
Command | ๐ง | โ |
Flyweight | ๐ง | โ |
Observer | ๐ง | โ |
Prototype | ๐ง | โ |
Singleton | ๐ง | โ |
State | ๐ง | โ |
Pattern | C++ (src/ ) |
---|---|
Double Buffer | โ |
Game Loop | โ |
Update Method | โ |
Pattern | C++ (src/ ) |
---|---|
Bytecode | โ |
Subclass Sandbox | โ |
Type Object | โ |
Pattern | C++ (src/ ) |
---|---|
Component | โ |
Event Queue | โ |
Service Locator | โ |
Pattern | C++ (src/ ) |
---|---|
Data Locality | ๐ง |
Dirty Flag | ๐ง |
Object Pool | ๐ง |
Spatial Partition | ๐ง |
- ๐ A detailed explanation
- ๐ฎ Usage examples in video games
- ๐ป Practical implementations in C++ (
src/
) or JavaScript (javascript/
)
git clone https://github.com/pigeonStrikesBack/pigeonstrikesback-game-dev-patterns.git
cd pigeonstrikesback-game-dev-patterns
Start with the theory in patterns/
to understand how each pattern works in a game context.
-
For C++ examples (
src/
):
To compile the C++ examples, you will need Raylib, a simple and easy-to-use game programming library in C. You can download and install it from the Raylib website.After Raylib is installed, you can use CMake to build the examples:
mkdir build cd build cmake .. make
The compiled binaries will appear in the
bin/
directory inside the build folder. -
For JavaScript examples (
javascript/
):
You can run them in your browser using the providedindex.html
files.
- Explore and implement classic and modern Game Programming Patterns
- Focus on performance, readability, and reusability
- Transition from high-level scripting (JS) to low-level systems (C++) to better reflect real-world game development
To build and run the C++ examples, you must have Raylib installed. Raylib is a simple and efficient game programming library. You can get it here:
Make sure to install Raylib or use the provided CMake configuration to link it to your project. If you're using a package manager like apt
, brew
, or zypper
, you can install it directly from there.