Skip to content

A header-only implementation of an entity-component system

License

Notifications You must be signed in to change notification settings

lchsk/simple-ecs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

simple-ecs

A simple header-only implementation of entity-component system

Installation

Just add include/simple_ecs.hpp to your source code.

It's a part of SFML gamedev libraries: https://github.com/lchsk/knight-libs

Example

#include "simple_ecs.hpp"

struct Position {
  int x;
  int y;

  Position(int x, int y) : x(x), y(y) {}
};

ecs::System system;

auto entity = system.create();

system.add<Position>(e, 3, 5);

auto &pos = entity->get<Position>();

std::cout << pos->x << std::endl; // prints 3

Building tests

Make sure that you have CMake and a C++ compiler installed.

You also need pkg-config and googletest.

Then open a terminal, go to the source directory and type the following commands:

$ mkdir build
$ cd build
$ cmake ..
$ make

Running tests

$ ctest

License

MIT