void level_snap(int i, const char *path) { char *filename; /* Convert the level name to a PNG filename. */ filename = concat_string(path, "/", base_name_sans(level_v[i].file, ".sol"), ".png", NULL); /* Initialize the game for a snapshot. */ if (game_client_init(level_v[i].file)) { union cmd cmd; cmd.type = CMD_GOAL_OPEN; game_proxy_enq(&cmd); game_client_sync(NULL); /* Render the level and grab the screen. */ video_clear(); game_client_fly(1.0f); game_kill_fade(); game_client_draw(POSE_LEVEL, 0); video_snap(filename); video_swap(); } free(filename); }
static int demo_play_enter(struct state *st, struct state *prev) { video_hide_cursor(); if (demo_paused) { demo_paused = 0; prelude = 0; audio_music_fade_in(0.5f); return 0; } /* * Post-1.5.1 replays include view data in the first update, this * line is currently left in for compatibility with older replays. */ game_client_fly(0.0f); if (check_compat && !game_compat_map) { goto_state(&st_demo_compat); return 0; } prelude = 1.0f; speed = SPEED_NORMAL; demo_replay_speed(speed); show_hud = 1; hud_update(0); hud_demo(); return demo_play_gui(); }
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); }
static int init_title_level(void) { if (game_client_init("map-medium/title.sol")) { union cmd cmd; cmd.type = CMD_GOAL_OPEN; game_proxy_enq(&cmd); game_client_sync(NULL); game_client_fly(1.0f); return 1; } return 0; }
static int play_loop_enter(struct state *st, struct state *prev) { rot_init(); fast_rotate = 0; if (prev == &st_pause) return 0; audio_play(AUD_GO, 1.f); game_client_fly(0.0f); show_hud = 1; hud_update(0); return play_loop_gui(); }
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); }