Beispiel #1
0
static void demo_play_timer(int id, float dt)
{
    game_step_fade(dt);
    gui_timer(id, dt);
    hud_timer(dt);

    /*
     * Introduce a one-second pause at the start of replay playback.  (One
     * second is the time during which the "Replay" label is being displayed.)
     * HACK ALERT!  "id == 0" means we got here from the pause screen, so no
     * label has been created and there's no need to wait.
     */

    if (id != 0 && time_state() < 1.0f)
        return;

    /* Spin or skip depending on how fast the demo wants to run. */

    if (!demo_replay_step(dt))
    {
        demo_paused = 0;
        goto_state(&st_demo_end);
    }
    else
        progress_step();
}
Beispiel #2
0
static void play_loop_timer(int id, float dt)
{
    float k = (fast_rotate ?
               (float) config_get_d(CONFIG_ROTATE_FAST) / 100.0f :
               (float) config_get_d(CONFIG_ROTATE_SLOW) / 100.0f);

    float r = 0.0f;

    gui_timer(id, dt);
    hud_timer(dt);

    switch (rot_get(&r))
    {
    case ROT_HOLD:
        /*
         * Cam 3 could be anything. But let's assume it's a manual cam
         * and holding down both rotation buttons freezes the camera
         * rotation.
         */
        game_set_rot(0.0f);
        game_set_cam(CAM_3);
        break;

    case ROT_ROTATE:
    case ROT_NONE:
        game_set_rot(r * k);
        game_set_cam(config_get_d(CONFIG_CAMERA));
        break;
    }

    game_step_fade(dt);

    game_server_step(dt);
    game_client_sync(demo_fp);
    game_client_blend(game_server_blend());

    switch (curr_status())
    {
    case GAME_GOAL:
        progress_stat(GAME_GOAL);
        goto_state(&st_goal);
        break;

    case GAME_FALL:
        progress_stat(GAME_FALL);
        goto_state(&st_fail);
        break;

    case GAME_TIME:
        progress_stat(GAME_TIME);
        goto_state(&st_fail);
        break;

    default:
        progress_step();
        break;
    }
}
Beispiel #3
0
static void play_set_timer(int id, float dt)
{
    float t = time_state();

    game_client_fly(0.5f - 0.5f * t);

    if (dt > 0.0f && t > 1.0f)
        goto_state(&st_play_loop);

    game_step_fade(dt);
    hud_cam_timer(dt);
    gui_timer(id, dt);
}
Beispiel #4
0
static void demo_play_timer(int id, float dt)
{
    game_step_fade(dt);
    gui_timer(id, dt);
    hud_timer(dt);

    /* Pause briefly before starting playback. */

    if (time_state() < prelude)
        return;

    if (!demo_replay_step(dt))
    {
        demo_paused = 0;
        goto_state(&st_demo_end);
    }
    else
    {
        progress_step();
        game_client_blend(demo_replay_blend());
    }
}
static void title_timer(int id, float dt)
{
    static const char *demo = NULL;
    float t;

    real_time += dt;

    switch (mode)
    {
    case 0: /* Mode 0: Pan across title level. */

        if (real_time <= 20.0f)
            game_set_fly(fcosf(V_PI * real_time / 20.0f));
        else
        {
            game_fade(+1.0f);
            real_time = 0.0f;
            mode = 1;
        }
        break;

    case 1: /* Mode 1: Fade out.  Load demo level. */

        if (real_time > 1.0f)
        {
            if ((demo = demo_pick()))
            {
                demo_replay_init(demo, NULL, NULL, NULL, NULL);
                demo_time = 0.0f;
                real_time = 0.0f;
                mode = 2;
            }
            else
            {
                game_fade(-1.0f);
                real_time = 0.0f;
                mode = 0;
            }
        }
        break;

    case 2: /* Mode 2: Run demo. */

        while (demo_time < real_time)
            if (demo_replay_step(&t))
                demo_time += t;
            else
            { 
                demo_replay_stop(0);
                game_fade(+1.0f);
                real_time = 0.0f;
                mode = 3;
            }
        break;

    case 3: /* Mode 3: Fade out.  Load title level. */

        if (real_time > 1.0f)
        {
            game_init("map-rlk/title.sol",
                      "map-back/jupiter.sol", "png/space.png", 0, 1);
            real_time = 0.0f;
            mode = 0;
        }
        break;
    }

    gui_timer(id, dt);
    audio_timer(dt);
    game_step_fade(dt);
}
Beispiel #6
0
static void title_timer(int id, float dt)
{
    static const char *demo = NULL;

    real_time += dt;

    switch (mode)
    {
    case MODE_LEVEL: /* Pan across title level. */

        if (real_time <= 20.0f)
        {
            game_client_fly(fcosf(V_PI * real_time / 20.0f));
        }
        else
        {
            game_fade(+1.0f);
            real_time = 0.0f;
            mode = MODE_LEVEL_FADE;
        }
        break;

    case MODE_LEVEL_FADE: /* Fade out.  Load demo level. */

        if (real_time > 1.0f)
        {
            if (!items)
                items = demo_dir_scan();

            if ((demo = pick_demo(items)))
            {
                demo_replay_init(demo, NULL, NULL, NULL, NULL, NULL);
                game_client_fly(0.0f);
                real_time = 0.0f;
                mode = MODE_DEMO;
            }
            else
            {
                game_fade(-1.0f);
                real_time = 0.0f;
                mode = MODE_LEVEL;
            }
        }
        break;

    case MODE_DEMO: /* Run demo. */

        if (!demo_replay_step(dt))
        {
            demo_replay_stop(0);
            game_fade(+1.0f);
            real_time = 0.0f;
            mode = MODE_DEMO_FADE;
        }
        else
            game_client_blend(demo_replay_blend());

        break;

    case MODE_DEMO_FADE: /* Fade out.  Load title level. */

        if (real_time > 1.0f)
        {
            init_title_level();

            real_time = 0.0f;
            mode = MODE_LEVEL;
        }
        break;
    }

    gui_timer(id, dt);
    game_step_fade(dt);
}
Beispiel #7
0
static void demo_compat_timer(int id, float dt)
{
    game_step_fade(dt);
    gui_timer(id, dt);
}
Beispiel #8
0
int game_step(const float g[3], float dt, int bt)
{
    struct s_file *fp = &file;

    float h[3];
    float d = 0.f;
    float b = 0.f;
    float t;
    int i, n = 1;

#ifdef REDUCE_PHYSICS
    static unsigned tn=0;
    tn++;
    sol_test_inc=((tn&1))+1;
    sol_test_inc2=((~tn&1))+1;
//    if ((tn&1))
//	sol_test_max=0.2333333f;
//    else
//	sol_test_max=0.3333333f;
#endif
    if (game_state)
    {
        t = dt;

        /* Smooth jittery or discontinuous input. */

        if (t < RESPONSE)
        {
            game_rx += (game_ix - game_rx) * t / RESPONSE;
            game_rz += (game_iz - game_rz) * t / RESPONSE;
        }
        else
        {
            game_rx = game_ix;
            game_rz = game_iz;
        }

        game_update_grav(h, g);
        part_step(h, t);

        if (jump_b)
        {
            jump_dt += t;

            /* Handle a jump. */

            if (0.5 < jump_dt)
            {
                fp->uv[0].p[0] = jump_p[0];
                fp->uv[0].p[1] = jump_p[1];
                fp->uv[0].p[2] = jump_p[2];
            }
            if (1.f < jump_dt)
                jump_b = 0;
        }
        else
        {
            /* Run the sim. */

            while (t > MAX_DT && n < MAX_DN)
            {
                t /= 2;
                n *= 2;
            }

            for (i = 0; i < n; i++)
                if (b < (d = sol_step(fp, h, t, 0, NULL)))
                    b = d;

            /* Mix the sound of a ball bounce. */

            if (b > 0.5)
                audio_play(AUD_BUMP, (b - 0.5f) * 2.0f);
        }

        game_step_fade(dt);
        game_update_view(dt);
        game_update_time(dt, bt);

        return game_update_state();
    }
    return GAME_NONE;
}