7 #define MAP_HEIGHT 1000
11 /* Type definitions */
15 unsigned char r, g, b;
26 struct material *material;
29 struct entity_step_data
48 bool collide_with_entities;
50 void (*on_step)(struct entity *self, struct entity_step_data stepdata);
51 void (*on_collide)(struct entity *self, int x, int y);
52 void (*on_collide_with_entity)(struct entity *self, struct entity *other);
53 void (*on_spawn)(struct entity *self, void *data);
54 void (*on_remove)(struct entity *self);
55 void (*on_death)(struct entity *self);
56 void (*on_damage)(struct entity *self, int damage);
65 struct generator_function
68 void (*callback)(int x, int y);
85 extern struct color black;
87 extern struct material wall;
88 extern struct material air;
89 extern struct material outside;
91 extern struct node map[MAP_WIDTH][MAP_HEIGHT];
93 extern struct entity player;
94 extern struct list *entities;
96 extern struct entity *entity_collision_map[MAP_WIDTH][MAP_HEIGHT];
98 struct color get_color(const char *str);
99 void set_color(struct color color, bool bg);
100 void light_color(struct color *color, double light);
101 void mix_color(struct color *color, struct color other, double ratio);
102 void dir_to_xy(enum direction dir, int *x, int *y);
103 struct list *add_element(struct list *list, void *element);
104 int clamp(int v, int max, int min);
105 int max(int a, int b);
106 int min(int a, int b);
107 void *make_buffer(void *ptr, size_t size);
112 struct node get_node(int x, int y);
113 bool is_outside(int x, int y);
114 bool is_solid(int x, int y);
116 bool spawn(struct entity def, int x, int y, void *data);
117 bool move(struct entity *entity, int xoff, int yoff);
118 void add_health(struct entity *entity, int health);
120 void register_air_function(struct generator_function func);
121 void register_input_handler(unsigned char c, struct input_handler handler);
122 void register_render_component(void (*callback)(struct winsize ws));