1
- kult :fire : <a href =" https://travis-ci.org/r-lyeh/kult " ><img src =" https://api.travis-ci.org/r-lyeh/kult.svg?branch=master " align =" right " /></a >
1
+ kult :crystal_ball : <a href =" https://travis-ci.org/r-lyeh/kult " ><img src =" https://api.travis-ci.org/r-lyeh/kult.svg?branch=master " align =" right " /></a >
2
2
====
3
3
4
- - Kult is a lightweight entity/component/system library written in C++11.
5
- - Kult is tiny.
6
- - Kult is header-only.
7
- - Kult is expressive.
8
- - Kult has no dependencies.
9
- - Kult is zlib/libpng licensed.
4
+ Kult is a lightweight entity/component/system library (C++11).
10
5
11
- ### sample
6
+ ## Features
7
+ - [x] Expressive.
8
+ - [x] Tiny, cross-platform, self-contained, header-only.
9
+ - [x] ZLIB/libPNG licensed.
10
+
11
+ ### Showcase
12
12
``` c++
13
13
#include < iostream>
14
14
#include " kult.hpp"
@@ -32,12 +32,11 @@ kult::component<'pos2', vec2> position;
32
32
kult::component<' vel2' , vec2> velocity;
33
33
34
34
// systems
35
- kult::system movement = [&]( double t, float dt ) {
35
+ kult::system< float > movement = [&]( float dt ) {
36
36
for( auto &entity : kult::join( position, velocity ) ) {
37
37
entity[ position ].x += entity[ velocity ].x * dt;
38
38
entity[ position ].y += entity[ velocity ].y * dt;
39
39
}
40
- return true;
41
40
};
42
41
43
42
// app
@@ -54,13 +53,49 @@ int main(int argc, const char **argv) {
54
53
55
54
// simulate 100 frames
56
55
for( int i = 0; i < 100; ++i ) {
57
- movement(0, 1/60.f);
56
+ movement( 1/60.f );
58
57
}
59
58
60
59
// print status
61
- std::cout << player.str() << std::endl;
62
- std::cout << enemy.str() << std::endl;
60
+ std::cout << player.dump() << std::endl;
61
+ std::cout << enemy.dump() << std::endl;
62
+
63
+ // purge entities
64
+ player.purge();
65
+ enemy.purge();
66
+
67
+ // print status
68
+ std::cout << player.dump() << std::endl;
69
+ std::cout << enemy.dump() << std::endl;
63
70
64
71
return 0;
65
72
}
66
73
```
74
+
75
+ ### Output
76
+ ```
77
+ { name: player #1 ,
78
+ desc: this is our warrior,
79
+ pos2: (x:3.33333,y:6.66666),
80
+ vel2: (x:2,y:4),
81
+ }
82
+ { name: orc #1 ,
83
+ pos2: (x:0,y:0),
84
+ }
85
+ {}
86
+ {}
87
+ ```
88
+
89
+ ### Reading
90
+ - https://github.com/sosolimited/Entity-Component-Samples
91
+
92
+ ### Alternatives
93
+ - https://github.com/alecthomas/entityx
94
+ - https://github.com/dbralir/ginseng
95
+ - https://github.com/miguelmartin75/anax
96
+ - https://github.com/Nocte-/es
97
+ - https://github.com/SuperV1234/SSVEntitySystem
98
+
99
+ ### Changelog
100
+ - v1.0.0 (2015/11/24): Allow external serializer; new entity methods; extra join/exclude sugars; improve dump info
101
+ - v0.0.0 (2014/05/04): Initial commit
0 commit comments