The Entity Component System of Brenta Engine. The ECS is a design pattern that allows you to structure your code in a way that is more modular and scalable.
You can read the official online documentation here.
Entities are objects in the game, It's just an ID:
Entity e = World::new_entity();Components are pieces of data that are attached to an entity:
struct PhysicsComponent : Component {
float mass;
float density;
glm::vec3 velocity;
glm::vec3 acceleration;
PhysicsComponent(float mass) : mass(mass) {}
};
// Somehwere
World::add_component<PhysicsComponent>(entity, 10.0f);
// or
e.add_component<PhysicsComponent>(10.0f);Systems are functions that operate on entities with specific
components. They are called at each game tick by the world:
struct FpsSystem : System<None> {
void run(std::vector<EntityId> _) const override {
text::render_text("FPS: " + std::to_string(time::get_fps()), 25.0f, 25.0f,
0.35f, glm::vec3(1.0f, 0.9f, 0.0f));
}
};To register you systems:
World::register_systems<FpsSystem>();Resources are like global data, accessible by any system:
struct MyResource : Resource {
int my_data;
bool is_ok;
MyResource() {}
}The library uses the engine's testing framework valFuzz. To run tests, follow the guide in tests/README.md.
The library is licensed under MIT license.