void switch_widescreen() { if (!setup_gfx() != 0) { allegro_message("Unable to setup the graphics mode\n"); exit(1); } }
int main() { std::srand(std::time(NULL)); allegro_init(); install_timer(); install_keyboard(); // install_mouse(); install_joystick(JOY_TYPE_AUTODETECT); override_config_file(redir("defnot.ini").c_str()); gfx_widescreen = get_config_int("Game", "Widescreen", gfx_widescreen); gfx_fullscreen = get_config_int("Game", "Fullscreen", gfx_fullscreen); if (!setup_gfx() != 0) { allegro_message("Unable to setup the graphics mode\n"); return 1; } // if (gfx_capabilities & GFX_HW_CURSOR) { // enable_hardware_cursor(); // select_mouse_cursor(MOUSE_CURSOR_ARROW); // show_mouse(screen); // } if (!load_media()) { allegro_message("Unable to load data files to play the game\n"); return 1; } // install the timer to control the game speed LOCK_VARIABLE(beats); LOCK_FUNCTION(timer_control); beats = 0; install_int_ex(timer_control, BPS_TO_TIMER(BPS)); // insert the callback routine for the close-button LOCK_VARIABLE(continuing); LOCK_FUNCTION(close_button); set_close_button_callback(close_button); // play the game game_loop(); set_config_int("Game", "Widescreen", gfx_widescreen); set_config_int("Game", "Fullscreen", gfx_fullscreen); remove_int(timer_control); allegro_exit(); return 0; }
int main(int argc, char** argv) { setup_gfx(); bool do_intro = true; string level; if (argc == 2) { level = argv[1]; do_intro = false; } else { level = "levels/walls.lvl"; } Mix_Music* music = Mix_LoadMUS("media/title.mp3"); music || DIE("Couldn't load music: " + Mix_GetError()); if (do_intro) { Mix_PlayMusic(music, 1); INTROFX = new EffectsManager; MOUSE_FOCUS = INTROFX; INTROFX->add( new SeqEffect( new DelayEffect(4), new SeqEffect( new SeqEffect( new FadeImageEffect( "media/chronic.png", vec(1.5, 1.25), vec(2.5, 1.75), 4, 4, 3), new FadeImageEffect( "media/soylent.png", vec(1.0, 1.25), vec(3.0, 1.75), 4, 4, 3)), new SeqEffect( new DelayEffect(2), new FadeImageEffect( "media/title.png", vec(0, 0.5), vec(4, 2.5), 4, 4, 4))))); } else { intro = false; start_game(level); } num overstep = 0; while (true) { events(); step(level); overstep -= STEP; // avoid degenerate behavior for expensive step()s. if (overstep > STEP) overstep = STEP; while (overstep <= STEP) { glClear(GL_COLOR_BUFFER_BIT); glLoadIdentity(); draw(overstep); SDL_GL_SwapBuffers(); overstep += get_time_diff(); } } Mix_FreeMusic(music); delete LEVEL; quit(); }