2#include <stdio.h>
3
4typedef struct {
5 double x, y;
6} Position, Velocity;
7
10 const Velocity *v =
ecs_field(it,
const Velocity, 1);
11
12 for (
int i = 0; i < it->
count; i ++) {
13 p[i].x += v[i].x;
14 p[i].y += v[i].y;
15 }
16}
17
19 const Position *p =
ecs_field(it,
const Position, 0);
20
21 for (
int i = 0; i < it->
count; i ++) {
23 p[i].x, p[i].y);
24 }
25}
26
27int main(int argc, char *argv[]) {
29
32
33
35
36
38
39
41 ecs_set(ecs, e1, Position, {10, 20});
42 ecs_set(ecs, e1, Velocity, {1, 2});
43
45 ecs_set(ecs, e2, Position, {10, 20});
46 ecs_set(ecs, e2, Velocity, {3, 4});
47
48
49
50
52
54}
FLECS_API bool ecs_progress(ecs_world_t *world, ecs_ftime_t delta_time)
Progress a world.
#define ECS_SYSTEM(world, id, phase,...)
Declare and define a system.
ecs_id_t ecs_entity_t
An entity identifier.
struct ecs_world_t ecs_world_t
A world is the container for all ECS data and supporting features.
#define ecs_entity(world,...)
Shorthand for creating an entity with ecs_entity_init().
#define ECS_COMPONENT(world, id)
Declare and define a component.
#define ecs_set(world, entity, component,...)
Set a component value.
#define ecs_field(it, T, index)
Get field data for a component.
const char * ecs_get_name(const ecs_world_t *world, ecs_entity_t entity)
Get the name of an entity.
int ecs_fini(ecs_world_t *world)
Delete a world.
ecs_world_t * ecs_init_w_args(int argc, char *argv[])
Create a new world with arguments.
int32_t count
Number of entities to iterate.
const ecs_entity_t * entities
Entity identifiers.