void game_step()

in procgen/src/games/caveflyer.cpp [287:324]


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

        if (special_action == 1) {
            float theta = -1 * agent->rotation + PI / 2;
            float vx = cos(theta);
            float vy = sin(theta);
            auto new_bullet = add_entity_rxy(agent->x, agent->y, vx, vy, 0.1f, 0.25f, PLAYER_BULLET);
            new_bullet->expire_time = 10;
            new_bullet->rotation = agent->rotation;
        }

        for (int ent_idx = (int)(entities.size()) - 1; ent_idx >= 0; ent_idx--) {
            auto ent = entities[ent_idx];
            if (ent->type == ENEMY) {
                ent->face_direction(ent->vx, ent->vy, -1 * PI / 2);
            }

            if (ent->type != PLAYER_BULLET)
                continue;

            bool found_wall = false;

            for (int i = 0; i < 2; i++) {
                for (int j = 0; j < 2; j++) {
                    int type2 = get_obj_from_floats(ent->x + ent->rx * (2 * i - 1), ent->y + ent->ry * (2 * j - 1));
                    found_wall = found_wall || type2 == CAVEWALL;
                }
            }

            if (found_wall) {
                ent->will_erase = true;
                spawn_child(ent, EXPLOSION, .5 * ent->rx);
            }
        }

        erase_if_needed();
    }