{
self->meta = malloc(sizeof(struct fireball_data));
*((struct fireball_data *) self->meta) = *((struct fireball_data *) data);
+
+ self->color.r = clamp(self->color.r + rand() % 65 - 32, 0, 255);
+ self->color.g = clamp(self->color.g + rand() % 65 - 32, 0, 255);
+ self->color.b = clamp(self->color.b + rand() % 65 - 32, 0, 255);
}
static void fireball_step(struct entity *self, struct entity_step_data stepdata)
}
}
+int clamp(int v, int min, int max)
+{
+ return v < min ? min : v > max ? max : v;
+}
+
/* Player */
static void player_death(struct entity *self)
void register_air_function(struct generator_function func);
void register_input_handler(unsigned char c, struct input_handler handler);
void dir_to_xy(int dir, int *x, int *y);
+int clamp(int v, int max, int min);
struct list *add_element(struct list *list, void *element);
#endif