in procgen/src/games/bossfight.cpp [348:413]
void game_step() override {
BasicAbstractGame::game_step();
// spawn_barriers();
shields->x = boss->x;
shields->y = boss->y;
rand_pct = rand_gen.rand01();
rand_fire_pct = rand_gen.rand01();
rand_pct_x = rand_gen.rand01();
rand_pct_y = rand_gen.rand01();
if (curr_vel_timeout <= 0) {
float dest_x = rand_pct_x * (main_width - 2 * BOSS_R) + BOSS_R;
float dest_y = rand_pct_y * (main_height - 2 * BOSS_R - BOTTOM_MARGIN) + BOSS_R + BOTTOM_MARGIN;
boss->vx = (dest_x - boss->x) / boss_vel_timeout;
boss->vy = (dest_y - boss->y) / boss_vel_timeout;
curr_vel_timeout = boss_vel_timeout;
if (time_to_swap > 0) {
time_to_swap -= 1;
} else {
if (shields_are_up) {
time_to_swap = vulnerable_duration;
} else {
time_to_swap = invulnerable_duration;
}
shields_are_up = !shields_are_up;
}
} else {
curr_vel_timeout -= 1;
}
if (special_action == 1 && (cur_time - last_fire_time) >= 3) {
auto new_bullet = add_entity(agent->x, agent->y, 0, PLAYER_BULLET_VEL, .25, PLAYER_BULLET);
new_bullet->image_theme = player_laser_theme;
new_bullet->collides_with_entities = true;
new_bullet->expire_time = 25;
last_fire_time = cur_time;
}
if (damaged_until_time >= cur_time) {
damaged_mode();
} else if (shields_are_up) {
active_attack();
} else {
passive_attack_mode();
}
for (int i = (int)(entities.size()) - 1; i >= 0; i--) {
auto ent = entities[i];
if (ent->type == ENEMY_BULLET) {
float v_trail = .5;
auto trail = add_entity_rxy(ent->x, ent->y, ent->vx * v_trail, ent->vy * v_trail, ent->rx, ent->ry, LASER_TRAIL);
trail->alpha_decay = 0.7f;
trail->image_type = ENEMY_BULLET;
trail->image_theme = boss_laser_theme;
trail->vrot = ent->vrot;
trail->rotation = ent->rotation;
trail->expire_time = 8;
}
}
}