1#ifndef SIMPLE_MODULE_H
2#define SIMPLE_MODULE_H
3
4
5#include "simple_module/bake_config.h"
6
7#ifdef __cplusplus
8extern "C" {
9#endif
10
11
12typedef struct {
13 double x, y;
14} Position, Velocity;
15
16
19
20
22
23#ifdef __cplusplus
24}
25#endif
26
27#endif
struct ecs_world_t ecs_world_t
A world is the container for all ECS data and supporting features.
#define ECS_COMPONENT_DECLARE(id)
Forward declare a component.
1#include <simple_module.h>
2#include <stdio.h>
3
6
7 for (
int i = 0; i < it->
count; i ++) {
8 printf("p = {%f, %f} (system)\n", p[i].x, p[i].y);
9 }
10}
11
12int main(int argc, char *argv[]) {
14
15
17
18
19
21
22
24 ecs_set(world, e, Velocity, {1, 2});
25
26
28
29
30 const Position *p =
ecs_get(world, e, Position);
31 printf("p = {%f, %f} (get)\n", p->x, p->y);
32
34
35
36
37
38}
#define ECS_IMPORT(world, id)
Wrapper around ecs_import().
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.
#define ecs_set(world, entity, component,...)
Set a component value.
#define ecs_get(world, entity, T)
Get a component.
#define ecs_insert(world,...)
Insert a new entity with a list of component values.
#define ecs_field(it, T, index)
Get field data for a component.
#define ecs_value(T,...)
Convenience macro for creating a compound literal value literal.
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.