8 #define MAP_HEIGHT 1000
12 /* Type definitions */
16 unsigned char r, g, b;
27 struct material *material;
30 struct entity_step_data
49 bool collide_with_entities;
51 void (*on_step)(struct entity *self, struct entity_step_data stepdata);
52 void (*on_collide)(struct entity *self, int x, int y);
53 void (*on_collide_with_entity)(struct entity *self, struct entity *other);
54 void (*on_spawn)(struct entity *self, void *data);
55 void (*on_remove)(struct entity *self);
56 void (*on_death)(struct entity *self);
57 void (*on_damage)(struct entity *self, int damage);
72 struct generator_function
76 void (*callback)(int x, int y, enum mg_context ctx);
88 void (*callback)(double dtime);
99 extern struct color black;
101 extern struct material wall;
102 extern struct material air;
103 extern struct material outside;
105 extern struct node map[MAP_WIDTH][MAP_HEIGHT];
107 extern struct entity player;
108 extern struct list *entities;
110 extern struct entity *entity_collision_map[MAP_WIDTH][MAP_HEIGHT];
112 struct color get_color(const char *str);
113 void set_color(struct color color, bool bg);
114 void light_color(struct color *color, double light);
115 void mix_color(struct color *color, struct color other, double ratio);
116 void dir_to_xy(enum direction dir, int *x, int *y);
117 struct list *add_element(struct list *list, void *element);
118 int clamp(int v, int max, int min);
119 int max(int a, int b);
120 int min(int a, int b);
121 void *make_buffer(void *ptr, size_t size);
122 double calculate_dtime(struct timespec from, struct timespec to);
123 void get_roman_numeral(int number, char **ptr, size_t *len);
128 struct node get_node(int x, int y);
129 bool is_outside(int x, int y);
130 bool is_solid(int x, int y);
132 bool spawn(struct entity def, int x, int y, void *data);
133 bool move(struct entity *entity, int xoff, int yoff);
134 void add_health(struct entity *entity, int health);
136 void register_air_function(struct generator_function func);
137 void register_input_handler(unsigned char c, struct input_handler handler);
138 void register_render_component(void (*callback)(struct winsize ws));
139 void register_globalstep(struct globalstep step);