1#include <run_callback.h>
2#include <iostream>
3
4
5
6
7
8struct Position {
9 double x, y;
10};
11
12struct Velocity {
13 double x, y;
14};
15
16int main(int, char *[]) {
18
19
21 ecs.
query<Position,
const Velocity>();
22
23
25 .set<Position>({10, 20})
26 .set<Velocity>({1, 2});
27
29 .set<Position>({10, 20})
30 .set<Velocity>({3, 4});
31
32
34 .set<Position>({10, 20});
35
36
38 std::cout << "Move begin\n";
39
41 auto p = it.
field<Position>(0);
42 auto v = it.
field<
const Velocity>(1);
43
44 for (auto i : it) {
46 p[i].x += v[i].x;
47 p[i].y += v[i].y;
49 << ": {" << p[i].x << ", " << p[i].y << "}\n";
50 }
51 }
52
53 std::cout << "Move end\n";
54 });
55
56
57
58
59
60
61}
conditional_t< sizeof...(Args)==0 &&_::is_sparse_query< Comps... >::value, flecs::sparse_query< Comps... >, flecs::query< Comps... > > query(Args &&... args) const
Create a query.
flecs::entity entity(Args &&... args) const
Create an entity.
flecs::string_view name() const
Return the entity name.
entity()
Default constructor.
Class for iterating over query results.
flecs::field< A > field(int8_t index) const
Get read-only access to field data.
bool next()
Progress iterator.
void run(Func &&func) const
Run the iterator.