void game_reset()

in procgen/src/games/dodgeball.cpp [259:369]


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

        options.center_agent = options.distribution_mode == MemoryMode;

        last_fire_time = 0;

        rooms.clear();
        rooms.push_back(QRectF(0, 0, main_width, main_height));

        int distribution_mode = options.distribution_mode;

        float thickness = 0.3f;
        float enemy_r = .5;
        float exit_r = .75;
        ball_r = .25;
        ball_vscale = .25;
        int num_iterations;
        int max_extra_enemies = 3;

        if (distribution_mode == EasyMode) {
            num_iterations = 2;
            thickness *= 2;
            enemy_r *= 2;
            ball_r *= 2;
            ball_vscale *= 2;
            maxspeed = .75;
            agent->rx = 1;
            agent->ry = 1;
            exit_r *= 2;
        } else if (distribution_mode == HardMode) {
            num_iterations = 4;
            thickness *= 1.5;
            enemy_r *= 1.5;
            ball_r *= 1.5;
            ball_vscale *= 1.5;
            maxspeed = .5;
            agent->rx = .75;
            agent->ry = .75;
        } else if (distribution_mode == ExtremeMode) {
            num_iterations = 8;
            maxspeed = .25;
        } else if (distribution_mode == MemoryMode) {
            num_iterations = 16;
            thickness *= 1.5;
            enemy_r *= 1.5;
            ball_r *= 1.5;
            ball_vscale *= 1.5;
            maxspeed = .5;
            agent->rx = .75;
            agent->ry = .75;
            max_extra_enemies = 16;
        } else {
            fassert(false);
        }

        hard_min_dim = 4 * agent->rx + 2 * thickness + .5;
        min_dim = agent->rx * 8 + .5;

        for (int iteration = 0; iteration < num_iterations; iteration++) {
            if (rooms.size() == 0)
                break;

            int idx = rand_gen.randn((int)(rooms.size()));
            QRectF room = rooms[idx];
            rooms.erase(rooms.begin() + idx);

            split_room(room, thickness);
        }

        float border_r = 0;

        float doorlen = 2 * exit_r;

        int exit_wall_choice = rand_gen.randn(4);

        if (exit_wall_choice == 0) {
            spawn_entity_rxy(doorlen / 2, exit_r, DOOR, 2 * border_r, 2 * border_r, main_width - 4 * border_r, 2 * exit_r);
        } else if (exit_wall_choice == 1) {
            spawn_entity_rxy(doorlen / 2, exit_r, DOOR, 2 * border_r, main_height - 2 * border_r - 2 * exit_r, main_width - 4 * border_r, 2 * exit_r);
        } else if (exit_wall_choice == 2) {
            spawn_entity_rxy(exit_r, doorlen / 2, DOOR, 2 * border_r, 2 * border_r, 2 * exit_r, main_height - 4 * border_r);
        } else if (exit_wall_choice == 3) {
            spawn_entity_rxy(exit_r, doorlen / 2, DOOR, main_width - 2 * border_r - 2 * exit_r, 2 * border_r, 2 * exit_r, main_height - 4 * border_r);
        }

        reposition_agent();

        num_enemies = rand_gen.randn(max_extra_enemies + 1) + 3;

        spawn_entities(num_enemies, enemy_r, ENEMY, 0, 0, main_width, main_height);

        int enemy_theme = rand_gen.randn(NUM_ENEMY_THEMES);

        for (auto ent : entities) {
            if (ent->type == ENEMY) {
                ent->image_theme = enemy_theme;
                ent->health = 1;
                ent->spawn_time = 0;
                ent->fire_time = 10;
                ent->collides_with_entities = true;
                ent->smart_step = true;
                choose_vel(ent);
                ent->face_direction(ent->vx, ent->vy);
            } else if (ent->type == LAVA_WALL) {
                ent->collides_with_entities = true;
            }
        }

        agent->face_direction(1, 0);
    }