+void enemy_collision_shots_dontcare(struct jumpnrun_enemy *self,
+ struct jumpnrun_game_state *state) {
+ (void) self;
+ (void) state;
+}
+
+static void enemy_tick_common(jumpnrun_enemy *self,
+ jumpnrun_game_state *state,
+ jumpnrun_level *lv,
+ jumpnrun_tile_range const *visible_tiles,
+ vec2d *player_inertia_mod) {
+ vec2d new_pos = enemy_pos_desired(self);
+ self->type->collision_tiles (self, &new_pos, lv, visible_tiles);
+ self->type->collision_player(self, state, player_inertia_mod);
+ enemy_move_to(self, new_pos);
+}
+
+void enemy_tick_straight_ahead(jumpnrun_enemy *self,
+ jumpnrun_game_state *state,
+ jumpnrun_level *lv,
+ jumpnrun_tile_range const *visible_tiles,
+ vec2d *player_inertia_mod) {
+ jumpnrun_passive_movement(&self->base.inertia);
+ enemy_tick_common(self, state, lv, visible_tiles, player_inertia_mod);
+ enemy_animation_advance(self);
+}
+
+void enemy_tick_straight_follow(jumpnrun_enemy *self,
+ jumpnrun_game_state *state,
+ jumpnrun_level *lv,
+ jumpnrun_tile_range const *visible_tiles,
+ vec2d *player_inertia_mod) {
+ jumpnrun_passive_movement(&self->base.inertia);
+ enemy_tick_common(self, state, lv, visible_tiles, player_inertia_mod);
+
+ if(fixed_point_lt(rectangle_right(&state->player.base.hitbox), rectangle_left(enemy_hitbox(self)))) {
+ self->base.inertia.x = self->type->spawn_inertia.x;
+ } else if(fixed_point_gt(rectangle_left(&state->player.base.hitbox), rectangle_right(enemy_hitbox(self)))) {
+ self->base.inertia.x = fixed_point_neg(self->type->spawn_inertia.x);
+ }
+
+ enemy_animation_advance(self);
+}
+
+void enemy_tick_swing_up_and_down(struct jumpnrun_enemy *self,
+ struct jumpnrun_game_state *state,
+ struct jumpnrun_level *lv,
+ struct jumpnrun_tile_range const *visible_tiles,
+ vec2d *player_inertia_mod) {
+ enemy_tick_common(self, state, lv, visible_tiles, player_inertia_mod);
+
+ self->base.inertia.y =
+ fixed_point_add(fixed_point_add(self->base.inertia.y,
+ fixed_point_div(self->type->spawn_inertia.y, FIXED_INT(3))),
+ fixed_point_mul(FIXED_POINT(0, 5),
+ fixed_point_sub(self->spawn_pos.y,
+ enemy_pos_display(self).y)));
+
+ enemy_animation_advance(self);
+}
+
+void enemy_tick_stationary(struct jumpnrun_enemy *self,
+ struct jumpnrun_game_state *state,
+ struct jumpnrun_level *lv,
+ struct jumpnrun_tile_range const *visible_tiles,
+ vec2d *player_inertia_mod) {
+ self->type->collision_tiles(self, &self->base.hitbox.pos, lv, visible_tiles);
+ self->type->collision_player(self, state, player_inertia_mod);
+
+ enemy_animation_advance(self);
+}
+
+void enemy_tick_jumper(jumpnrun_enemy *self,
+ jumpnrun_game_state *state,
+ jumpnrun_level *lv,
+ jumpnrun_tile_range const *visible_tiles,
+ vec2d *player_inertia_mod) {
+ jumpnrun_passive_movement(&self->base.inertia);
+ enemy_tick_common(self, state, lv, visible_tiles, player_inertia_mod);
+
+ if(jumpnrun_moveable_touching_ground(&self->base)) {
+ self->base.inertia.y = self->type->spawn_inertia.y;
+ }
+
+ enemy_animation_advance(self);
+}
+
+void enemy_tick_dog(jumpnrun_enemy *self,
+ jumpnrun_game_state *state,
+ jumpnrun_level *lv,
+ jumpnrun_tile_range const *visible_tiles,
+ vec2d *player_inertia_mod) {
+ jumpnrun_passive_movement(&self->base.inertia);
+ enemy_tick_common(self, state, lv, visible_tiles, player_inertia_mod);
+
+ if(self->base.tick_minor % self->type->animation_ticks_per_frame == 0) {
+ switch(self->base.tick_minor / self->type->animation_ticks_per_frame) {
+ case 12:
+ self->base.tick_minor = 0;
+ case 0:
+ case 2:
+ case 4:
+ case 6:
+ self->base.anim_frame = 0;
+ if(self->base.flags & JUMPNRUN_MOVEABLE_MIRRORED) {
+ self->base.inertia.x = fixed_point_neg(self->type->spawn_inertia.x);
+ } else {
+ self->base.inertia.x = self->type->spawn_inertia.x;
+ }
+
+ break;
+
+ case 1:
+ case 3:
+ case 5:
+ case 7:
+ self->base.anim_frame = 1;
+ if(self->base.flags & JUMPNRUN_MOVEABLE_MIRRORED) {
+ self->base.inertia.x = fixed_point_neg(self->type->spawn_inertia.x);
+ } else {
+ self->base.inertia.x = self->type->spawn_inertia.x;
+ }
+ break;
+
+ case 8:
+ case 10:
+ self->base.anim_frame = 2;
+ self->base.inertia.x = FIXED_INT(0);
+ break;
+
+ case 9:
+ case 11:
+ self->base.anim_frame = 3;
+ self->base.inertia.x = FIXED_INT(0);
+ break;
+ }
+ }
+
+ ++self->base.tick_minor;
+}
+
+void enemy_tick_giraffe(jumpnrun_enemy *self,
+ jumpnrun_game_state *state,
+ jumpnrun_level *lv,
+ jumpnrun_tile_range const *visible_tiles,
+ vec2d *player_inertia_mod) {
+ bool was_on_ground = jumpnrun_moveable_touching_ground(&self->base);
+
+ jumpnrun_passive_movement(&self->base.inertia);
+ enemy_tick_common(self, state, lv, visible_tiles, player_inertia_mod);
+
+ if(jumpnrun_moveable_touching_ground(&self->base)) {
+ if(was_on_ground) {
+ enemy_animation_advance(self);
+ if(self->base.anim_frame == 0) {
+ self->base.inertia = self->type->spawn_inertia;
+
+ if(fixed_point_gt(rectangle_mid_x(&state->player.base.hitbox), rectangle_mid_x(enemy_hitbox(self)))) {
+ self->base.inertia.x = fixed_point_neg(self->base.inertia.x);
+ }
+ }
+ } else {
+ self->base.tick_minor = 0;
+ self->base.anim_frame = 3;
+ self->base.inertia.x = FIXED_INT(0);
+ }
+ } else if(was_on_ground) {
+ self->base.tick_minor = 0;
+ self->base.anim_frame = 1;
+ } else if(self->base.anim_frame == 1) {
+ enemy_animation_advance(self);
+ }
+
+ ++self->base.tick_minor;
+}
+
+void enemy_tick_fly_straight(struct jumpnrun_enemy *self,
+ struct jumpnrun_game_state *state,
+ struct jumpnrun_level *lv,
+ struct jumpnrun_tile_range const *visible_tiles,
+ vec2d *player_inertia_mod) {
+ enemy_tick_common(self, state, lv, visible_tiles, player_inertia_mod);
+ enemy_animation_advance(self);
+}
+
+void enemy_tick_fly_straight_and_dip(struct jumpnrun_enemy *self,
+ struct jumpnrun_game_state *state,
+ struct jumpnrun_level *lv,
+ struct jumpnrun_tile_range const *visible_tiles,
+ vec2d *player_inertia_mod) {
+ if(fixed_point_lt(fixed_point_abs(fixed_point_sub(enemy_pos_hitbox(self).x,
+ state->player.base.hitbox.pos.x)),
+ FIXED_INT(20))) {
+ self->base.flags |= JUMPNRUN_ENEMY_EVENT_TRIGGER1;
+ }
+
+ if(self->base.flags & JUMPNRUN_ENEMY_EVENT_TRIGGER1) {
+ self->base.inertia.y =
+ fixed_point_add(fixed_point_add(self->base.inertia.y,
+ fixed_point_div(self->type->spawn_inertia.y, FIXED_INT(3))),
+ fixed_point_mul(FIXED_POINT(0, 5),
+ fixed_point_sub(self->spawn_pos.y,
+ enemy_pos_hitbox(self).y)));
+ } else {
+ self->base.inertia.y = FIXED_INT(0);
+ }
+
+ enemy_tick_common(self, state, lv, visible_tiles, player_inertia_mod);
+ enemy_animation_advance(self);
+}
+