+void enemy_tick_giraffe(jumpnrun_enemy *self,
+ jumpnrun_game_state *state,
+ jumpnrun_level *lv,
+ jumpnrun_tile_range const *visible_tiles,
+ vec2d *player_inertia_mod) {
+ int screenpos = fixed_point_cast_int(rectangle_left(&self->base.current_box));
+
+ if(screenpos + JUMPNRUN_MAX_SPAWN_MARGIN < state->left ||
+ screenpos >= state->left + BADGE_DISPLAY_WIDTH + JUMPNRUN_MAX_SPAWN_MARGIN) {
+ return;
+ }
+
+ bool was_on_ground = self->base.touching_ground;
+
+ jumpnrun_passive_movement(&self->base.inertia);
+
+ vec2d new_pos = vec2d_add(enemy_position(self), self->base.inertia);
+ self->type->collision_tiles(self, &new_pos, lv, visible_tiles);
+ self->type->collision_player(self, state, player_inertia_mod);
+ rectangle_move_to(&self->base.current_box, new_pos);
+
+ if(self->base.touching_ground) {
+ if(was_on_ground) {
+ enemy_animation_advance(self);
+ if(self->base.anim_frame == 0) {
+ if(self->flags & JUMPNRUN_ENEMY_FACING_RIGHT) {
+ self->base.inertia.x = fixed_point_neg(self->type->spawn_inertia.x);
+ self->base.inertia.y = self->type->spawn_inertia.y;
+ } else {
+ self->base.inertia = self->type->spawn_inertia;
+ }
+ }
+ } 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;
+ if (fixed_point_lt(self->base.inertia.x, FIXED_INT(0))) { self->flags &= ~JUMPNRUN_ENEMY_FACING_RIGHT; }
+ else if(fixed_point_ne(self->base.inertia.x, FIXED_INT(0))) { self->flags |= JUMPNRUN_ENEMY_FACING_RIGHT; }
+}
+