Need help with kult?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

r-lyeh-archived
126 Stars 4 Forks zlib License 14 Commits 4 Opened issues

Description

:crystal_ball: Lightweight entity/component/system library (C++11)

Services available

!
?

Need anything else?

Contributors list

# 105,726
public-...
cpp11
Racket
osx
1 commit

kult :crystal_ball:

Kult is a lightweight entity/component/system library (C++11).

Features

  • [x] Expressive.
  • [x] Tiny, cross-platform, self-contained, header-only.
  • [x] ZLIB/libPNG licensed.

Showcase

#include 
#include "kult.hpp"

// custom type struct vec2 { float x, y;

template<typename t> friend T&amp;operator&lt; name;

kult::component description; kult::component position; kult::component velocity;

// systems kult::system movement = [&]( float dt ) { for( auto &entity : kult::join( position, velocity ) ) { entity[ position ].x += entity[ velocity ].x * dt; entity[ position ].y += entity[ velocity ].y * dt; } };

// app int main(int argc, const char **argv) {

// assign properties dynamically
player[ name ] = "player #1";
player[ position ] = { 0, 0 };
player[ velocity ] = { 2, 4 };
player[ description ] = "this is our warrior";

enemy[ name ] = "orc #1";
enemy[ position ] = { 0, 0 };

// simulate 100 frames
for( int i = 0; i &lt; 100; ++i ) {
    movement( 1/60.f );
}

// print status
std::cout &lt;&lt; player.dump() &lt;&lt; std::endl;
std::cout &lt;&lt; enemy.dump() &lt;&lt; std::endl;

// purge entities
player.purge();
enemy.purge();

// print status
std::cout &lt;&lt; player.dump() &lt;&lt; std::endl;
std::cout &lt;&lt; enemy.dump() &lt;&lt; std::endl;

return 0;

}

Output

{       name: player #1,
        desc: this is our warrior,
        pos2: (x:3.33333,y:6.66666),
        vel2: (x:2,y:4),
}
{       name: orc #1,
        pos2: (x:0,y:0),
}
{}
{}

Reading

  • https://github.com/sosolimited/Entity-Component-Samples

Alternatives

  • https://github.com/alecthomas/entityx
  • https://github.com/dbralir/ginseng
  • https://github.com/miguelmartin75/anax
  • https://github.com/Nocte-/es
  • https://github.com/SuperV1234/SSVEntitySystem

Changelog

  • v1.0.0 (2015/11/24): Allow external serializer; new entity methods; extra join/exclude sugars; improve dump info
  • v0.0.0 (2014/05/04): Initial commit

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.