1#include <fwd_declare_component.h>
2#include <stdio.h>
3
4
5
6
7
8
9
10
11
12
13
14
15typedef struct {
16 double x, y;
17} Position;
18
19
20
22
23
24
25
26
27
28
29
30
31
32
33
34
36
37
39
42
43
44 ecs_set(world, result, Position, {10, 20});
46
47
48
49
51
52 return result;
53}
54
55int main(int argc, char *argv[]) {
57
58
60
61
63
64
66
67
69 const Position *p =
ecs_get(world, e, Position);
70 printf("{%f, %f}\n", p->x, p->y);
71
72
73 printf("Id of Position is %u\n",
74 (uint32_t)
ecs_id(Position));
75
77
78
79
80
81}
void ecs_add_id(ecs_world_t *world, ecs_entity_t entity, ecs_id_t component)
Add a (component) ID to an entity.
FLECS_API const ecs_entity_t ecs_id(EcsDocDescription)
Component ID for EcsDocDescription.
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.
ecs_entity_t ecs_new(ecs_world_t *world)
Create new entity ID.
#define ecs_add(world, entity, T)
Add a component to an entity.
#define ECS_DECLARE(id)
Forward declare an entity, tag, prefab, or any other entity identifier.
#define ECS_COMPONENT_DEFINE(world, id_)
Define a forward-declared component.
#define ECS_TAG_DEFINE(world, id_)
Define a forward-declared tag.
#define ECS_COMPONENT_DECLARE(id)
Forward declare a component.
#define ecs_set(world, entity, component,...)
Set a component value.
#define ecs_get(world, entity, T)
Get a component.
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.