ECS Template
Entity Component System engine in C++20 with modular architecture
C++ · ECS · Game Engine · SFML · Architecture
Universal Entity Component System engine in C++20. Modular architecture, reusable for all types of 2D games.
Context
ECS engine born from the second-year Jeu Libre project (March to May 2025), then extracted and published as a reusable template.
Goal: create a reusable engine as a base for other projects, with a clean and extensible architecture.
What it does
Supported game types:
- Real-time: FPS, platformers, action
- Turn-based: strategy, tactical RPG
- Grid-based: roguelikes, puzzles
- Hybrid: mode combinations
Architecture:
- Entities as pure IDs
- Components as data
- Systems for behavior
- Total logic/data decoupling
Demo: Pirate Space Explorer - complete game (30+ Components, 35 Systems) shipped inside the repo as a showcase.
Links
ECS Architecture
Pure Entity-Component-System architecture:
Entity (ID)
│
├── Component A (Data)
├── Component B (Data)
└── Component C (Data)
│
└── Systems (Behavior)
├── Active (continuous)
├── Reactive (event-driven)
└── TurnBased (discrete)
Tech Stack
| Tech | Version | Role |
|---|---|---|
| C++ | 20 | Core language |
| SFML | 2.5+ | 2D rendering |
| CMake | 3.20+ | Build system |
| Patterns | ECS, Factory, Observer | Architecture |
Statistics
- 36 Components modular
- 35 Systems decoupled
- 8+ Modules: core, transform, graphics, gameplay, inventory, interaction, AI, audio, network
Collision Optimizations
Spatial hashing O(n) vs O(n²):
| Entities | Brute Force | Spatial Hash | Speedup |
|---|---|---|---|
| 125 | 125,000 checks | 1,000 checks | 25x |
| 1000 | 500,000 checks | 2,000 checks | 250x |
Memory Safety
- Smart pointers + RAII
- Memory pooling for frequent allocations
- Thread-safe with mutexes and atomics