-
Notifications
You must be signed in to change notification settings - Fork 5
/
demo3.cc
34 lines (27 loc) · 840 Bytes
/
demo3.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <iostream>
#include "kult.hpp"
struct vec2 {
float x, y;
template<typename T> friend T&operator<<( T &os, const vec2 &self ) {
return os << "(x:" << self.x << ",y:" << self.y << ")", os;
}
};
using namespace kult;
using position = component<'pos2', vec2>;
using velocity = component<'vel2', vec2>;
void movementSystem( float delta ) {
for( auto &id : join<position,velocity>() ) {
get<position>(id).x += get<velocity>(id).x * delta;
get<position>(id).y += get<velocity>(id).y * delta;
}
};
int main(int argc, char **argv) {
int player = id();
add<position>(player) = { 0, 0 };
add<velocity>(player) = { 2, 4 };
for( unsigned times = 0; times < 100; ++times ) {
movementSystem(0.0016f);
std::cout << dump(player) << std::endl;
}
return 0;
}