6 #define MAP_HEIGHT 1000
10 /* Type definitions */
14 unsigned char r, g, b;
25 struct material *material;
28 struct entity_step_data
46 bool collide_with_entities;
48 void (*on_step)(struct entity *self, struct entity_step_data stepdata);
49 void (*on_collide)(struct entity *self, int x, int y);
50 void (*on_collide_with_entity)(struct entity *self, struct entity *other);
51 void (*on_spawn)(struct entity *self, void *data);
52 void (*on_remove)(struct entity *self);
53 void (*on_death)(struct entity *self);
54 void (*on_damage)(struct entity *self, int damage);
63 struct generator_function
66 void (*callback)(int x, int y);
83 extern struct color black;
85 extern struct material wall;
86 extern struct material air;
87 extern struct material outside;
89 extern struct node map[MAP_WIDTH][MAP_HEIGHT];
91 extern struct entity player;
92 extern struct list *entities;
94 extern struct entity *entity_collision_map[MAP_WIDTH][MAP_HEIGHT];
96 struct color get_color(const char *str);
97 void set_color(struct color color, bool bg);
98 void light_color(struct color *color, double light);
99 void mix_color(struct color *color, struct color other, double ratio);
100 void dir_to_xy(enum direction dir, int *x, int *y);
101 struct list *add_element(struct list *list, void *element);
102 int clamp(int v, int max, int min);
103 int max(int a, int b);
104 int min(int a, int b);
109 struct node get_node(int x, int y);
110 bool is_outside(int x, int y);
111 bool is_solid(int x, int y);
113 bool spawn(struct entity def, int x, int y, void *data);
114 bool move(struct entity *entity, int xoff, int yoff);
115 void add_health(struct entity *entity, int health);
117 void register_air_function(struct generator_function arg);
118 void register_input_handler(unsigned char c, struct input_handler arg);
119 void register_render_component(void (*arg)(struct winsize ws));