bool OverlayScoreboard::RepaintIfNeeded() { bool bRepainted = false; if (m_bNeedsRepaint) { SDL_Surface *pSurface = m_pFuncGetActiveOverlay(); // if the overlay is visible if (m_bVisible) { // for Dragon's Lair/Space Ace if (!m_bThayers) { // Draw all DL/SA scoreboard labels. // Credits Label draw_string("Credits", pSurface->w / 12 - (pSurface->w == 360 ? 4 : 3), 0, pSurface); // Player labels. draw_string("Player 1: ", 1, 0, pSurface); draw_string("Player 2: ", pSurface->w / 6 - 19, 0, pSurface); // Lives labels. draw_string("Lives: ", 1, 1, pSurface); draw_string("Lives: ", pSurface->w / 6 - 10, 1, pSurface); // Update Player Scores update_player_score(pSurface, 0, 0, m_DigitValues + this->PLAYER1_0, 6); update_player_score(pSurface, 1, 0, m_DigitValues + this->PLAYER2_0, 6); // Update Player Lives update_player_lives(pSurface, 0, m_DigitValues[this->LIVES0]); update_player_lives(pSurface, 1, m_DigitValues[this->LIVES1]); } // for Thayer's Quest else { // Thayer's Quest only uses "Credits" portion of the DL/SA // scoreboard. draw_string("Time", pSurface->w / 12 - 2, 0, pSurface); } // Update Credits update_credits(pSurface); } // else the overlay is invisible, so erase the surface else { SDL_FillRect(pSurface, NULL, 0); } bRepainted = true; m_bNeedsRepaint = false; } return bRepainted; }
void game_over_init(void) { winsys_set_display_func( main_loop ); winsys_set_idle_func( main_loop ); winsys_set_reshape_func( reshape ); winsys_set_mouse_func( mouse_cb ); winsys_set_motion_func( ui_event_motion_func ); winsys_set_passive_motion_func( ui_event_motion_func ); remove_all_bonuses(); halt_sound( "flying_sound" ); halt_sound( "rock_sound" ); halt_sound( "ice_sound" ); halt_sound( "snow_sound" ); play_music( "game_over" ); aborted = g_game.race_aborted; if ( !aborted ) { update_player_score( get_player_data( local_player() ) ); } if ( (!g_game.practicing &&!aborted) || (!g_game.practicing && aborted && !game_abort_is_for_tutorial())) { race_won = was_current_race_won(); init_starting_tutorial_step(-100); } g_game.needs_save_or_display_rankings=false; g_game.rankings_displayed=false; }
// the flagstatus is determined by a flag, a status and possibly 2 players (carrier and killer) void set_flagstatus( int flagstatus, int flag_nr, int flagcarrier ) { /* ** -----Base------<------ ** | | | ** | \|/ | ** | | | ** | Carried--->---Captured ** | | | ** | \|/ /|\ ** | | | ** -<--Field ** */ int prev; // process queue like FLAGS[ flag_nr ].previously = FLAGS[ flag_nr ].currently; FLAGS[ flag_nr ].currently = flagstatus; prev = FLAGS[ flag_nr ].previously; switch ( flagstatus ) { case FS_CARRIED : // this is considered a flagtake FLAGS[ flag_nr ].carrier = flagcarrier; FLAGS[ flag_nr ].current_alive_touches++; // update playerscore if ( FLAGS[ flag_nr ].current_alive_touches == 1 ) { update_player_score( PE_FIRST_TOUCH, flagcarrier, 1 ); } else { update_player_score( PE_FLAG_TOUCH, flagcarrier, 1 ); } break; case FS_FIELD : FLAGS[ flag_nr ].carrier = NO_PLAYER; break; case FS_CAPTURED : if ( FLAGS[ flag_nr ].current_alive_touches == 1 ) { // coast to coast capture //PLAYERS[ flagcarrier ].coast_to_coast++; update_player_score( PE_COAST_TO_COAST, flagcarrier, 1 ); } else { update_player_score( PE_FLAG_CAPTURE, flagcarrier, 1 ); } if ( FLAGS[ flag_nr ].current_alive_touches > FLAGS[ flag_nr ].max_touches_capped ) { FLAGS[ flag_nr ].max_touches_capped = FLAGS[ flag_nr ].current_alive_touches; } FLAGS[ flag_nr ].capped++; // this should be taken care of in FS_BASE, but maybe the "flag returned to base" message // won't come if something is wrong in a map FLAGS[ flag_nr ].carrier = NO_PLAYER; FLAGS[ flag_nr ].current_alive_touches = 0; break; case FS_BASE : if ( prev == FS_FIELD ) { // saved if ( FLAGS[ flag_nr ].current_alive_touches > FLAGS[ flag_nr ].max_touches_saved ) { FLAGS[ flag_nr ].max_touches_saved = FLAGS[ flag_nr ].current_alive_touches; } FLAGS[ flag_nr ].saved++; // update saved counter } FLAGS[ flag_nr ].carrier = NO_PLAYER; FLAGS[ flag_nr ].current_alive_touches = 0; // reset break; } }