void game_step()

in procgen/src/games/plunder.cpp [194:241]


    void game_step() override {
        BasicAbstractGame::game_step();

        juice_left -= 0.0015f;

        if (rand_gen.rand01() < spawn_prob) {
            float ent_r = r_scale;
            int lane = rand_gen.randn(num_lanes);
            float ent_y = (lane * .11 + .4) * (main_height / 2 - ent_r) + main_height / 2;
            float moves_right = lane_directions[lane];
            float ent_vx = lane_vels[lane] * (moves_right ? 1 : -1);
            auto ent = std::make_shared<Entity>(0, ent_y, ent_vx, 0, ent_r, SHIP);
            ent->image_type = SHIP;
            ent->image_theme = image_permutation[rand_gen.randn(num_current_ship_types)];
            match_aspect_ratio(ent);
            ent->x = moves_right ? -1 * ent_r : (main_width + ent_r);
            ent->is_reflected = !moves_right;

            if (!has_any_collision(ent)) {
                entities.push_back(ent);
            }
        }

        if (special_action == 1 && (cur_time - last_fire_time) >= 3) {
            auto new_bullet = add_entity(agent->x, agent->y, 0, 1, .25, PLAYER_BULLET);
            new_bullet->collides_with_entities = true;
            new_bullet->expire_time = 50;
            last_fire_time = cur_time;
            juice_left -= 0.02f;
        }

        if (juice_left <= 0) {
            step_data.done = true;
        } else if (juice_left >= 1) {
            juice_left = 1;
        }

        if (targets_hit >= target_quota) {
            step_data.done = true;
            step_data.reward += COMPLETION_BONUS;
            step_data.level_complete = true;
        }

        // don't collide with legend
        if (agent->x < min_agent_x) {
            agent->x = min_agent_x;
        }
    }