void DoEndLevelScoreGlitzPoll( int nitems, newmenu_item * menus, int * key, int citem ) { if ( timer_get_approx_seconds() > time_out_value ) { *key = -2; } }
void autodemo_menu_check(int nitems, newmenu_item * items, int *last_key, int citem ) { int curtime; nitems = nitems; items=items; citem = citem; //draw copyright message if ( Menu_draw_copyright ) { Menu_draw_copyright = 0; gr_set_current_canvas(NULL); gr_set_curfont(GAME_FONT); gr_set_fontcolor(BM_XRGB(6,6,6),-1); gr_printf(0x8000,grd_curcanv->cv_bitmap.bm_h-GAME_FONT->ft_h-2,TXT_COPYRIGHT); } // Don't allow them to hit ESC in the main menu. if (*last_key==KEY_ESC) *last_key = 0; if ( do_auto_demo ) { curtime = timer_get_approx_seconds(); //if ( ((keyd_time_when_last_pressed+i2f(20)) < curtime) && ((last_joy_time+i2f(20)) < curtime) && (!speedtest_on) ) { if ( ((keyd_time_when_last_pressed+i2f(45)) < curtime) && (!speedtest_on) ) { keyd_time_when_last_pressed = curtime; // Reset timer so that disk won't thrash if no demos. newdemo_start_playback(NULL); // Randomly pick a file if (Newdemo_state == ND_STATE_PLAYBACK) { Function_mode = FMODE_GAME; *last_key = -2; } } } }
void main (void) { fix t1, t2, t3, delta, mdelta, mt3; printf( "Press any key to start...\n" ); timer_init(); timer_set_rate( 9943 ); t1 = t2 = timer_get_fixed_seconds(); mdelta = 0; mt3 = 0; while(!kbhit()) { t3 = t2; t1 = timer_get_approx_seconds(); t2 = timer_get_fixed_seconds(); delta = t2 - t1; if ( abs(delta) > mdelta ) mdelta = abs(delta); if ( abs(t2-t3) > mt3 ) mt3 = abs(t2-t3); printf( "%.8f\t%.8f\t%.8f\t%d\t%.8f\t%.8f\n", f2fl(t2), f2fl(t2-t1), f2fl(mdelta), TICKER/19, f2fl(t2-t3), f2fl(mt3) ); // if ( t2 < t1 ) { // printf( "Bad time of %.8f\n", f2fl(t1-t2) ); // } } }
void DoGameOver() { time_out_value = timer_get_approx_seconds() + i2f(60*5); nm_messagebox1( TXT_GAME_OVER, DoEndLevelScoreGlitzPoll, 1, TXT_OK, "" ); if (Current_mission_num == 0) scores_maybe_add_player(0); Function_mode = FMODE_MENU; Game_mode = GM_GAME_OVER; longjmp( LeaveGame, 0 ); // Exit out of game loop }
void DoGameOver() { time_out_value = timer_get_approx_seconds() + i2f(60*5); // nm_messagebox1( TXT_GAME_OVER, DoEndLevelScoreGlitzPoll, 1, TXT_OK, "" ); #ifndef SHAREWARE if (PLAYING_BUILTIN_MISSION) #endif scores_maybe_add_player(0); Function_mode = FMODE_MENU; Game_mode = GM_GAME_OVER; longjmp( LeaveGame, 1 ); // Exit out of game loop }
// ----------------------------------------------------------------------------- // Does the bonus scoring. // Call with dead_flag = 1 if player died, but deserves some portion of bonus (only skill points), anyway. void DoEndLevelScoreGlitz(int network) { int level_points, skill_points, energy_points, shield_points, hostage_points; int all_hostage_points; int endgame_points; char all_hostage_text[64]; char endgame_text[64]; #define N_GLITZITEMS 9 char m_str[N_GLITZITEMS][30]; newmenu_item m[9]; int i,c; char title[128]; int is_last_level; gr_palette_load( gr_palette ); set_screen_mode(SCREEN_MENU); level_points = Players[Player_num].score-Players[Player_num].last_score; if (!Cheats_enabled) { if (Difficulty_level > 1) { skill_points = level_points*(Difficulty_level-1)/2; skill_points -= skill_points % 100; } else skill_points = 0; shield_points = f2i(Players[Player_num].shields) * 10 * (Difficulty_level+1); energy_points = f2i(Players[Player_num].energy) * 5 * (Difficulty_level+1); hostage_points = Players[Player_num].hostages_on_board * 500 * (Difficulty_level+1); } else { skill_points = 0; shield_points = 0; energy_points = 0; hostage_points = 0; } all_hostage_text[0] = 0; endgame_text[0] = 0; if (!Cheats_enabled && (Players[Player_num].hostages_on_board == Players[Player_num].hostages_level)) { all_hostage_points = Players[Player_num].hostages_on_board * 1000 * (Difficulty_level+1); sprintf(all_hostage_text, "%s%i\n", TXT_FULL_RESCUE_BONUS, all_hostage_points); } else all_hostage_points = 0; if (!Cheats_enabled && !(Game_mode & GM_MULTI) && (Players[Player_num].lives) && (Current_level_num == Last_level)) { //player has finished the game! endgame_points = Players[Player_num].lives * 10000; sprintf(endgame_text, "%s%i\n", TXT_SHIP_BONUS, endgame_points); is_last_level=1; } else endgame_points = is_last_level = 0; add_bonus_points_to_score(skill_points + energy_points + shield_points + hostage_points + all_hostage_points + endgame_points); c = 0; sprintf(m_str[c++], "%s%i", TXT_SHIELD_BONUS, shield_points); // Return at start to lower menu... sprintf(m_str[c++], "%s%i", TXT_ENERGY_BONUS, energy_points); sprintf(m_str[c++], "%s%i", TXT_HOSTAGE_BONUS, hostage_points); sprintf(m_str[c++], "%s%i", TXT_SKILL_BONUS, skill_points); sprintf(m_str[c++], "%s", all_hostage_text); if (!(Game_mode & GM_MULTI) && (Players[Player_num].lives) && (Current_level_num == Last_level)) sprintf(m_str[c++], "%s", endgame_text); sprintf(m_str[c++], "%s%i\n", TXT_TOTAL_BONUS, shield_points+energy_points+hostage_points+skill_points+all_hostage_points+endgame_points); sprintf(m_str[c++], "%s%i", TXT_TOTAL_SCORE, Players[Player_num].score); for (i=0; i<c; i++) { m[i].type = NM_TYPE_TEXT; m[i].text = m_str[i]; } // m[c].type = NM_TYPE_MENU; m[c++].text = "Ok"; if (Current_level_num < 0) sprintf(title,"%s%s %d %s\n %s %s",is_last_level?"\n\n\n":"\n",TXT_SECRET_LEVEL, -Current_level_num, TXT_COMPLETE, Current_level_name, TXT_DESTROYED); else sprintf(title,"%s%s %d %s\n%s %s",is_last_level?"\n\n\n":"\n",TXT_LEVEL, Current_level_num, TXT_COMPLETE, Current_level_name, TXT_DESTROYED); Assert(c <= N_GLITZITEMS); time_out_value = timer_get_approx_seconds() + i2f(60*5); #ifdef NETWORK if ( network && (Game_mode & GM_NETWORK) ) newmenu_do2(NULL, title, c, m, network_endlevel_poll2, 0, Menu_pcx_name); else #endif // Note link! newmenu_do2(NULL, title, c, m, DoEndLevelScoreGlitzPoll, 0, Menu_pcx_name); }
// ----------------------------------------------------------------------------- // Return true if message got aborted by user (pressed ESC), else return false. int show_briefing_message(int screen_num, char *message) { int prev_ch=-1; int ch, done=0; briefing_screen *bsp = &Briefing_screens[screen_num]; int delay_count = KEY_DELAY_DEFAULT; int key_check; int robot_num=-1; int rval=0; int tab_stop=0; int flashing_cursor=0; int new_page=0; int text_ulx = rescale_x(bsp->text_ulx); int text_uly = rescale_y(bsp->text_uly); Bitmap_name[0] = 0; Current_color = 0; // mprintf((0, "Going to print message [%s] at x=%i, y=%i\n", message, x, y)); gr_set_curfont( GAME_FONT ); init_char_pos(text_ulx, text_uly); while (!done) { ch = *message++; if (ch == '$') { ch = *message++; if (ch == 'C') { Current_color = get_message_num(&message)-1; Assert((Current_color >= 0) && (Current_color < MAX_BRIEFING_COLORS)); prev_ch = 10; } else if (ch == 'F') { // toggle flashing cursor flashing_cursor = !flashing_cursor; prev_ch = 10; while (*message++ != 10) ; } else if (ch == 'T') { tab_stop = get_message_num(&message); prev_ch = 10; // read to eoln } else if (ch == 'R') { if (Robot_canv != NULL) {free(Robot_canv); Robot_canv=NULL;} init_spinning_robot(); robot_num = get_message_num(&message); prev_ch = 10; // read to eoln } else if (ch == 'N') { //--grs_bitmap *bitmap_ptr; if (Robot_canv != NULL) {free(Robot_canv); Robot_canv=NULL;} get_message_name(&message, Bitmap_name); strcat(Bitmap_name, "#0"); Animating_bitmap_type = 0; prev_ch = 10; } else if (ch == 'O') { if (Robot_canv != NULL) {free(Robot_canv); Robot_canv=NULL;} get_message_name(&message, Bitmap_name); strcat(Bitmap_name, "#0"); Animating_bitmap_type = 1; prev_ch = 10; } else if (ch == 'B') { char bitmap_name[32]; grs_bitmap guy_bitmap; ubyte temp_palette[768]; int iff_error; if (Robot_canv != NULL) {free(Robot_canv); Robot_canv=NULL;} get_message_name(&message, bitmap_name); strcat(bitmap_name, ".bbm"); gr_init_bitmap_data (&guy_bitmap); iff_error = iff_read_bitmap(bitmap_name, &guy_bitmap, BM_LINEAR, temp_palette); Assert(iff_error == IFF_NO_ERROR); show_briefing_bitmap(&guy_bitmap); gr_free_bitmap_data (&guy_bitmap); prev_ch = 10; // } else if (ch == 'B') { // if (Robot_canv != NULL) // {free(Robot_canv); Robot_canv=NULL;} // // bitmap_num = get_message_num(&message); // if (bitmap_num != -1) // show_briefing_bitmap(Textures[bitmap_num]); // prev_ch = 10; // read to eoln } else if (ch == 'S') { int keypress; fix start_time; fix time_out_value; start_time = timer_get_fixed_seconds(); start_time = timer_get_approx_seconds(); time_out_value = start_time + i2f(60*5); // Wait 1 minute... //added on 9/13/98 by adb to make arch's requiring updates work gr_update(); //end changes by adb while ( (keypress = local_key_inkey()) == 0 ) { // Wait for a key if ( timer_get_approx_seconds() > time_out_value ) { keypress = 0; break; // Time out after 1 minute.. } while (timer_get_fixed_seconds() < start_time + KEY_DELAY_DEFAULT/2) ; flash_cursor(flashing_cursor); show_spinning_robot_frame(robot_num); show_bitmap_frame(); //added on 9/13/98 by adb to make arch's requiring updates work gr_update(); //end changes by adb start_time += KEY_DELAY_DEFAULT/2; } #ifndef NDEBUG if (keypress == KEY_BACKSP) Int3(); #endif if (keypress == KEY_ESC) rval = 1; flashing_cursor = 0; done = 1; } else if (ch == 'P') { // New page. new_page = 1; while (*message != 10) { message++; // drop carriage return after special escape sequence } message++; prev_ch = 10; //Begin D1X addition } else if (ch == '$' || ch == ';') { // Print a $/; prev_ch = ch; Briefing_text_x += show_char_delay((char) ch, delay_count, robot_num, flashing_cursor); //End D1X addition } } else if (ch == '\t') { // Tab if (Briefing_text_x - text_ulx < tab_stop) Briefing_text_x = text_ulx + tab_stop; } else if ((ch == ';') && (prev_ch == 10)) { while (*message++ != 10) ; prev_ch = 10; } else if (ch == '\\') { prev_ch = ch; } else if (ch == 10) { if (prev_ch != '\\') { prev_ch = ch; Briefing_text_y += GAME_FONT->ft_h+GAME_FONT->ft_h*3/5; Briefing_text_x = text_ulx; if (Briefing_text_y > text_uly + rescale_y(bsp->text_height)) { load_briefing_screen(screen_num); Briefing_text_x = text_ulx; Briefing_text_y = text_uly; } } else { if (ch == 13) Int3(); prev_ch = ch; } } else { prev_ch = ch; Briefing_text_x += show_char_delay((char) ch, delay_count, robot_num, flashing_cursor); } //added/changed on 9/13/98 by adb to speed up briefings after pressing a key with SDL // Check for Esc -> abort. if(delay_count) key_check=local_key_inkey(); else key_check=0; //end change - adb if ( key_check == KEY_ESC ) { rval = 1; done = 1; } if ( key_check == KEY_ALTED+KEY_F2 ) title_save_game(); if ((key_check == KEY_SPACEBAR) || (key_check == KEY_ENTER)) delay_count = 0; if (Briefing_text_x > text_ulx + rescale_x(bsp->text_width)) { Briefing_text_x = text_ulx; Briefing_text_y += GAME_FONT->ft_h+GAME_FONT->ft_h*3/5; } if ((new_page) || (Briefing_text_y > text_uly + rescale_y(bsp->text_height))) { fix start_time = 0; fix time_out_value = 0; int keypress; new_page = 0; start_time = timer_get_approx_seconds(); time_out_value = start_time + i2f(60*5); // Wait 1 minute... //added on 9/13/98 by adb to make arch's requiring updates work gr_update(); //end changes by adb while ( (keypress = local_key_inkey()) == 0 ) { // Wait for a key if ( timer_get_approx_seconds() > time_out_value ) { keypress = 0; break; // Time out after 1 minute.. } while (timer_get_approx_seconds() < start_time + KEY_DELAY_DEFAULT/2) ; flash_cursor(flashing_cursor); show_spinning_robot_frame(robot_num); show_bitmap_frame(); //added on 9/13/98 by adb to make arch's requiring updates work gr_update(); //end changes by adb start_time += KEY_DELAY_DEFAULT/2; } robot_num = -1; #ifndef NDEBUG if (keypress == KEY_BACKSP) Int3(); #endif if (keypress == KEY_ESC) { rval = 1; done = 1; } load_briefing_screen(screen_num); Briefing_text_x = text_ulx; Briefing_text_y = text_uly; delay_count = KEY_DELAY_DEFAULT; } } if (Robot_canv != NULL) {free(Robot_canv); Robot_canv=NULL;} return rval; }