5 #define MAP_HEIGHT 1000
13 unsigned char r, g, b;
24 struct material *material;
27 struct entity_step_data
45 bool collide_with_entities;
47 void (*on_step)(struct entity *self, struct entity_step_data stepdata);
48 void (*on_collide)(struct entity *self, int x, int y);
49 void (*on_collide_with_entity)(struct entity *self, struct entity *other);
50 void (*on_spawn)(struct entity *self, void *data);
51 void (*on_remove)(struct entity *self);
52 void (*on_death)(struct entity *self);
53 void (*on_damage)(struct entity *self, int damage);
62 typedef struct entity *render_entity_list[LIGHT * 2 + 1][LIGHT * 2 + 1];
64 struct generator_function
67 void (*callback)(int x, int y);
86 extern struct color black;
88 extern struct material wall;
89 extern struct material air;
90 extern struct material outside;
92 extern struct node map[MAP_WIDTH][MAP_HEIGHT];
94 extern struct entity player;
95 extern struct list *entities;
97 extern struct entity *entity_collision_map[MAP_WIDTH][MAP_HEIGHT];
99 extern struct list *air_functions;
101 extern struct input_handler *input_handlers[256];
104 struct color get_color(const char *str);
105 bool is_outside(int x, int y);
106 struct node get_node(int x, int y);
107 bool is_solid(int x, int y);
108 bool move(struct entity *entity, int xoff, int yoff);
109 bool spawn(struct entity def, int x, int y, void *data);
110 void add_health(struct entity *entity, int health);
111 void add_score(int s);
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 register_air_function(struct generator_function func);
117 void register_input_handler(unsigned char c, struct input_handler handler);
118 void dir_to_xy(enum direction dir, int *x, int *y);
119 int clamp(int v, int max, int min);
120 struct list *add_element(struct list *list, void *element);