/* There was going to be a nice fadeout effect using the allegro fade_out and fade_in functions, but for some reason these screwed up the palette. Oh well. */ void end_game(int fade_speed) { // fade_out(fade_speed); rest(1000 / fade_speed); clear_keybuf(); clear_bitmap(screen); // set_palette(palet); init_palette(); set_palette(palet); int challenge_winner = 0; if (arena[0].teams == 0) challenge_winner = score_table(); else challenge_winner = score_table_team(); if (arena[0].challenge_level != 0) { if (challenge_winner == 0) { switch(arena[0].challenge_level) { case 1: information_box("", "Norbert won?", "Hmm.", 0); break; case 2: information_box("", "Looks like you need some more practice.", "", 0); break; case 3: information_box("", "Sorry, you lose.", "", 0); break; case 4: information_box("", "Good, but not great.", "", 0); break; case 5: information_box("", "Oh well, better luck next time.", "", 0); break; case 6: information_box("", "Almost there. Try again.", "", 0); break; case 7: information_box("", "Very good, but not quite good enough.", "", 0); break; } end_challenge(); } } if (arena[0].qstart != QSTART_NONE) end_qstart(); //shutdown_network(); // fade_in(*palet, fade_speed); // set_palette(*palet); do { } while (keypressed() == 0); clear_keybuf(); //net_init(); }
/* the main program body */ int main(int argc, char *argv[]) { ALLEGRO_PATH *font_path; int w = 0, h = 0; int www = FALSE; int i, n; int display_flags = ALLEGRO_GENERATE_EXPOSE_EVENTS; srand(time(NULL)); al_set_org_name("liballeg.org"); al_set_app_name("SPEED"); if (!al_init()) { fprintf(stderr, "Could not initialise Allegro.\n"); return 1; } al_init_primitives_addon(); /* parse the commandline */ for (i=1; i<argc; i++) { if (strcmp(argv[i], "-cheat") == 0) { cheat = TRUE; } else if (strcmp(argv[i], "-simple") == 0) { low_detail = TRUE; } else if (strcmp(argv[i], "-nogrid") == 0) { no_grid = TRUE; } else if (strcmp(argv[i], "-nomusic") == 0) { no_music = TRUE; } else if (strcmp(argv[i], "-www") == 0) { www = TRUE; } else if (strcmp(argv[i], "-fullscreen") == 0) { /* if no width is specified, assume fullscreen_window */ display_flags |= w ? ALLEGRO_FULLSCREEN : ALLEGRO_FULLSCREEN_WINDOW; } else { n = atoi(argv[i]); if (!n) { usage(); return 1; } if (!w) { w = n; if (display_flags & ALLEGRO_FULLSCREEN_WINDOW) { /* toggle from fullscreen_window to fullscreen */ display_flags &= ~ALLEGRO_FULLSCREEN_WINDOW; display_flags |= ALLEGRO_FULLSCREEN; } } else if (!h) { h = n; } else { usage(); return 1; } } } /* it's a real shame that I had to take this out! */ if (www) { printf( "\n" "Unfortunately the built-in web browser feature had to be removed.\n" "\n" "I did get it more or less working as of Saturday evening (forms and\n" "Java were unsupported, but tables and images were mostly rendering ok),\n" "but the US Department of Justice felt that this was an unacceptable\n" "monopolistic attempt to tie in web browsing functionality to an\n" "unrelated product, so they threatened me with being sniped at from\n" "the top of tall buildings by guys with high powered rifles unless I\n" "agreed to disable this code.\n" "\n" "We apologise for any inconvenience that this may cause you.\n" ); return 1; } if (!w || !h) { if (argc == 1 || (display_flags & ALLEGRO_FULLSCREEN_WINDOW)) { w = 640; h = 480; } else { usage(); return 1; } } /* set the screen mode */ al_set_new_display_option(ALLEGRO_SAMPLE_BUFFERS, 1, ALLEGRO_SUGGEST); al_set_new_display_option(ALLEGRO_SAMPLES, 4, ALLEGRO_SUGGEST); al_set_new_display_flags(display_flags); screen = al_create_display(w, h); if (!screen) { fprintf(stderr, "Error setting %dx%d display mode\n", w, h); return 1; } al_init_image_addon(); /* The Allegro 5 port introduced an external data dependency, sorry. * To avoid performance problems on graphics drivers that don't support * drawing to textures, we build up transition screens on memory bitmaps. * We need a font loaded into a memory bitmap for those, then a font * loaded into a video bitmap for the game view. Blech! */ font_path = get_resources_path(); al_set_path_filename(font_path, "a4_font.tga"); al_init_font_addon(); al_set_new_bitmap_flags(ALLEGRO_MEMORY_BITMAP); font = al_load_bitmap_font(al_path_cstr(font_path, '/')); if (!font) { fprintf(stderr, "Error loading %s\n", al_path_cstr(font_path, '/')); return 1; } al_set_new_bitmap_flags(ALLEGRO_VIDEO_BITMAP); font_video = al_load_bitmap_font(al_path_cstr(font_path, '/')); if (!font_video) { fprintf(stderr, "Error loading %s\n", al_path_cstr(font_path, '/')); return 1; } al_destroy_path(font_path); /* set up everything else */ al_install_keyboard(); al_install_joystick(); if (al_install_audio()) { if (!al_reserve_samples(8)) al_uninstall_audio(); } init_input(); init_sound(); init_hiscore(); /* the main program body */ while (title_screen()) { if (play_game()) { show_results(); score_table(); } } /* time to go away now */ shutdown_hiscore(); shutdown_sound(); goodbye(); shutdown_input(); al_destroy_font(font); al_destroy_font(font_video); return 0; }