1#include <hello_world.h>
2#include <stdio.h>
3
4typedef struct {
5 double x;
6 double y;
7} Position, Velocity;
8
9
10
11
15
16
18 printf("Move entities with [%s]\n", type_str);
19 ecs_os_free(type_str);
20
21
22 for (
int i = 0; i < it->
count; i ++) {
23 p[i].x += v[i].x;
24 p[i].y += v[i].y;
25 }
26}
27
28int main(int argc, char *argv[]) {
29
31
32
35
36
38
39
43
44
46 ecs_set(world, Bob, Position, {0, 0});
47 ecs_set(world, Bob, Velocity, {1, 2});
49
50
53
54
55 const Position *p =
ecs_get(world, Bob, Position);
56 printf("Bob's position is {%f, %f}\n", p->x, p->y);
57
59
60
61
62
63
64}
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.
char * ecs_table_str(const ecs_world_t *world, const ecs_table_t *table)
Convert a table to a string.
#define ecs_add_pair(world, subject, first, second)
Add a pair to an entity.
#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_TAG(world, id)
Declare and define a tag.
#define ecs_set(world, entity, component,...)
Set a component value.
#define ecs_get(world, entity, T)
Get a component.
#define ecs_field(it, T, index)
Get field data for 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.
ecs_table_t * table
Current table.
int32_t count
Number of entities to iterate.