⚛️ P-E-R-R-Y ECS
A modern, lightweight Entity-Component-System framework in C++.

✨ Overview
P-E-R-R-Y ECS is a header-only, type-safe library for game development, simulations, or any system that benefits from separating data from logic.
It implements the Entity-Component-System (ECS) pattern with modern C++ features:
- Templates & variadic functions for type safety
- Optional concepts (C++20) for system constraints
- Efficient storage and fast iteration
Core goals:
- 🧩 Component-oriented storage with type-safety
- ⚡ Fast lookups via
SparseArray and type-based storage
- 🔄 Flexible Systems: can operate on any combination of components
- ✅ Unit-tested with GoogleTest
- 🚀 Header-only, easy integration
🧱 Features
- Create entities and attach any combination of components
- Add systems that operate on specific components
- Variadic interface: add multiple components or systems at once
- Owned (rvalue) vs Non-owned (lvalue) systems
- Safe runtime updates via
Registry::callSystem<System>()
- Component access via
getComponents<T>()
🧩 Example Usage
#include <memory>
struct Velocity { int x, y; };
struct Position { int x, y; void operator+=(const Velocity& vel) { x += vel.x; y += vel.y; } };
struct Health { int value; };
public:
MoveSystem() {}
for(size_t i = 0; i < positions.size(); ++i) {
if (positions[i] && velocities[i])
positions[i].value() += velocities[i].value();
}
}
};
int main() {
using MyComponents = std::tuple<Position, Velocity, Health >;
Health h{100};
}
Entity class from ECS.
Definition Entity.hpp:29
void addComponent(Component &&... c)
add a component to the entity using the registryRef method addComponent
Definition Entity_impl.hpp:27
define the Registry class
Definition Registry.hpp:47
void addComponent(Entity const &to, Component &&...c)
Definition Registry_impl.hpp:53
Entity createEntity()
handling entities (define in Registry.cpp)
Definition Registry.cpp:14
void callSystem()
call a system
Definition Registry_impl.hpp:96
SparseArray< Component > & getComponents()
get components of a given type
Definition Registry_impl.hpp:43
void addSystem(System &s)
handling systems
Definition Registry_impl.hpp:71
void registerComponentsByExtraction()
register every components by extraction from a tuple
Definition Registry_impl.hpp:36