1#include <basics_json.h>
2#include <stdio.h>
3
4typedef struct {
5 float x, y;
6} Position;
7
8int main(int argc, char *argv[]) {
10
11
13
14
16 .entity =
ecs_id(Position),
17 .members = {
20 }
21 });
22
23
25 ecs_set(ecs, ent, Position, {10, 20});
26
27
28 const Position *ptr =
ecs_get(ecs, ent, Position);
30 printf("Position = %s\n", str);
31 ecs_os_free(str);
32
33
35 printf("ent = %s\n", str);
36 ecs_os_free(str);
37
38
39
40
41
42
43
44
45
46
48}
FLECS_API const ecs_entity_t ecs_id(EcsDocDescription)
Component ID for EcsDocDescription.
FLECS_API char * ecs_ptr_to_json(const ecs_world_t *world, ecs_entity_t type, const void *data)
Serialize value into JSON string.
FLECS_API char * ecs_entity_to_json(ecs_world_t *world, ecs_entity_t entity, const ecs_entity_to_json_desc_t *desc)
Serialize entity into JSON string.
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_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.