1#include <entity_event.h>
2#include <stdio.h>
3
4
5
6
7
8
9
10
11
12
13
14
15
16
18
19
20typedef struct {
21 double width, height;
22} Resize;
23
25
27
28
30 printf("clicked on %s!\n", path);
31 ecs_os_free(path);
32}
33
35
36 Resize *p = it->
param;
38 printf("resized %s to {%.0f, %.0f}!\n", path, p->width, p->height);
39 ecs_os_free(path);
40}
41
42int main(int argc, char *argv[]) {
44
47
48
50
51
52
54 .query.terms = {{ .id =
EcsAny, .src.id = widget }},
55 .events = { Click },
56 .callback = OnClick
57 });
58
59
61 .query.terms = {{ .id =
EcsAny, .src.id = widget }},
62 .events = {
ecs_id(Resize) },
63 .callback = OnResize
64 });
65
66
68 .event = Click,
69 .entity = widget
70 });
71
72
75 .entity = widget,
76 .param = &(Resize){100, 200}
77 });
78
80
81
82
83
84}
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.
#define ECS_TAG_DECLARE
Forward declare a tag.
#define ecs_entity(world,...)
Shorthand for creating an entity with ecs_entity_init().
#define ECS_COMPONENT_DEFINE(world, id_)
Define a forward-declared component.
#define ecs_observer(world,...)
Shorthand for creating an observer with ecs_observer_init().
#define ECS_TAG_DEFINE(world, id_)
Define a forward-declared tag.
#define ECS_COMPONENT_DECLARE(id)
Forward declare a component.
#define ecs_get_path(world, child)
Get path from root.
ecs_entity_t ecs_field_src(const ecs_iter_t *it, int8_t index)
Return the field source.
void ecs_emit(ecs_world_t *world, ecs_event_desc_t *desc)
Send an event.
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.
void * param
Param passed to ecs_run().