Back to index

extremetuxracer  0.5beta
Public Member Functions | Static Public Attributes | Protected Member Functions | Private Attributes
GameOver Class Reference

#include <game_over.h>

Inheritance diagram for GameOver:
Inheritance graph
[legend]
Collaboration diagram for GameOver:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 GameOver ()
 ~GameOver ()
void loop (float timeStep)
bool keyPressEvent (SDLKey key)
bool mouseButtonEvent (int button, int x, int y, bool pressed)
virtual bool keyboardEvent (SDLKey key, bool release)
virtual bool keyReleaseEvent (SDLKey key)
virtual bool mouseButtonPressEvent (int button, int x, int y)
virtual bool mouseButtonReleaseEvent (int button, int x, int y)

Static Public Attributes

static GameModecurrentMode = NULL
static game_mode_t mode
static game_mode_t prevmode

Protected Member Functions

void drawSnow (float timeStep, bool windy=false)
 custom function for drawing snow in the ui

Private Attributes

bool m_aborted
bool m_bestScore
pp::Labelmp_raceOverLbl
pp::Labelmp_timeLbl
pp::Labelmp_herringLbl
pp::Labelmp_scoreLbl
pp::Labelmp_maxspeedLbl
pp::Labelmp_flyingLbl
pp::Labelmp_highscoreLbl
pp::Labelmp_resultsLbl
pp::Labelmp_raceOverOutlineLbl
pp::Labelmp_timeOutlineLbl
pp::Labelmp_herringOutlineLbl
pp::Labelmp_scoreOutlineLbl
pp::Labelmp_maxspeedOutlineLbl
pp::Labelmp_flyingOutlineLbl
pp::Labelmp_highscoreOutlineLbl
pp::Labelmp_resultsOutlineLbl

Detailed Description

Definition at line 28 of file game_over.h.


Constructor & Destructor Documentation

Definition at line 51 of file game_over.cpp.

{
       halt_sound( "flying_sound" );
    halt_sound( "rock_sound" );
    halt_sound( "ice_sound" );
    halt_sound( "snow_sound" );

       if( Benchmark::getMode() != Benchmark::NONE ){
              Benchmark::displayState();
              winsys_exit( 0 );
       }
              
if (gameMgr->gametype!=GameMgr::PRACTICING) {
std::string mus = gameMgr->currentEvent->music;
mus += "_game_over";
play_music( (char *)mus.c_str() );
}
else
{
play_music("game_over");
}


    m_aborted = gameMgr->wasRaceAborted();

       if ( !m_aborted ) {
              gameMgr->updatePlayersScores();
    }
              
    if ( gameMgr->gametype!=GameMgr::PRACTICING ) {
              m_bestScore = gameMgr->updateCurrentRaceData();         
              
              if(!gameMgr->wasRaceWon()){
                     players[0].decLives();
            //We have tried it and failed, and we have to play it next to advance
            if(players[0].getLives()>0) {
                gameMgr->setRaceHasToBeRetried(true);
            } else {
                //We cant play it any more, since we dont have any lives left...
                gameMgr->setRaceHasToBeRetried(false);
            }

              }
    else{ //race was won
      gameMgr->setRaceHasToBeRetried(false);
    }
    }else{
              if ( !m_aborted ) {
                     m_bestScore = players[0].updateOpenCourseData(
                                                               gameMgr->getCurrentRace().name,
                                                               gameMgr->time,
                                                               players[0].herring,
                                                               players[0].score);
                     
                     if(m_bestScore) players[0].saveData();
              }
       }
       
       {  
       pp::Vec3d dir = players[0].vel;
       int speed = int(dir.normalize());
       //set max_speed
       if (speed > players[0].max_speed) players[0].max_speed=int(speed);
       }
       
       int width = getparam_x_resolution();
    int height = getparam_y_resolution();
       
       pp::Vec2d pos(width/2, height/2 +200);
       
       if ( gameMgr->wasRaceAborted() ) {
              mp_raceOverLbl = new pp::Label(pos,"race_over",_("Race aborted"));
              mp_raceOverLbl->alignment.center();
              mp_raceOverOutlineLbl = new pp::Label(pos,"race_over_outline",_("Race aborted"));
              mp_raceOverOutlineLbl->alignment.center();
    }else{    
              mp_raceOverLbl = new pp::Label(pos,"race_over",_("Race Over"));
              mp_raceOverLbl->alignment.center();
              mp_raceOverOutlineLbl = new pp::Label(pos,"race_over_outline",_("Race Over"));
              mp_raceOverOutlineLbl->alignment.center();
       
              char buff[BUFF_LEN];
              int minutes, seconds, hundredths;

              getTimeComponents( gameMgr->time, minutes, seconds, hundredths );
              sprintf( buff, _("Time: %02d:%02d.%02d"), minutes, seconds, hundredths );    
              pos.y-=100;
              mp_timeLbl = new pp::Label(pos,"race_stats",buff);
              mp_timeLbl->alignment.center();
              mp_timeOutlineLbl = new pp::Label(pos,"race_stats_outline",buff);
              mp_timeOutlineLbl->alignment.center();
       
              sprintf( buff, _("Herring: %3d"), players[0].herring );
              pos.y-=30;
              mp_herringLbl = new pp::Label(pos,"race_stats",buff);
              mp_herringLbl->alignment.center();
              mp_herringOutlineLbl = new pp::Label(pos,"race_stats_outline",buff);
              mp_herringOutlineLbl->alignment.center();
       
              sprintf( buff, _("Score: %6d"), players[0].score );
              pos.y-=30;
              mp_scoreLbl = new pp::Label(pos,"race_stats",buff);
              mp_scoreLbl->alignment.center();
              mp_scoreOutlineLbl = new pp::Label(pos,"race_stats_outline",buff);
              mp_scoreOutlineLbl->alignment.center();
       
              int speed = int((double)players[0].max_speed * M_PER_SEC_TO_KM_PER_H);
              sprintf( buff, _("Max speed: %3d km/h"), speed);
              pos.y-=30;
              mp_maxspeedLbl = new pp::Label(pos,"race_stats",buff);
              mp_maxspeedLbl->alignment.center();
              mp_maxspeedOutlineLbl = new pp::Label(pos,"race_stats_outline",buff);
              mp_maxspeedOutlineLbl->alignment.center();
       
              double percent = (gameMgr->airbornetime / gameMgr->time) * 100.0;
              sprintf( buff, _("Was flying: %.01f %% of time"), percent);
              pos.y-=30;
              mp_flyingLbl = new pp::Label(pos,"race_stats",buff);
              mp_flyingLbl->alignment.center();
              mp_flyingOutlineLbl = new pp::Label(pos,"race_stats_outline",buff);
              mp_flyingOutlineLbl->alignment.center();
              
              char buff2[50];
              snprintf(buff2, 50, "");
              if(highscore::useHighscore) {
                     int pos = Highscore->addScore(gameMgr->getCurrentRace().name,players[0].name,players[0].score);
                     if(pos != -1)
                            snprintf(buff2, 50, _("You made it to the %s place in the highscore!"),highscore::posToStr(pos).c_str());
              }
              pos.y-=30;
              mp_highscoreLbl = new pp::Label(pos,"race_stats",buff2);
              mp_highscoreLbl->alignment.center();
              mp_highscoreOutlineLbl = new pp::Label(pos,"race_stats_outline",buff2);
              mp_highscoreOutlineLbl->alignment.center();
       
              const char *string="";
       
              if ( gameMgr->gametype==GameMgr::PRACTICING){
                     if(m_bestScore){
                            string = _("You beat your best score!");
                     }
              } else if(gameMgr->wasEventWon()){
                     string = _("Congratulations! You won the campaign!");
              } else if(gameMgr->wasCupWon()){
                     string = _("Congratulations! You won the cup!");
              } else if(gameMgr->wasRaceWon()){
                     string = _("Requirements met! Advance to the next race.");
              } else {
                     string = _("Race requirements not met.");
              }      
       
              pos.y-=30;
              if (gameMgr->wasRaceWon()) {
                     mp_resultsLbl = new pp::Label(pos,"race_results",string);
                     mp_resultsLbl->alignment.center();}
              else{
                     mp_resultsLbl = new pp::Label(pos,"race_results_fail",string);
                     mp_resultsLbl->alignment.center();}

              mp_resultsOutlineLbl = new pp::Label(pos,"race_results_outline",string);
              mp_resultsOutlineLbl->alignment.center();
       }
}

Here is the call graph for this function:

Definition at line 215 of file game_over.cpp.

{
    if(gameMgr->getCurrentRace().snowing) reset_snow();
//erase "game over" text from screen
       delete mp_raceOverLbl;
//erase "game over" outline
       delete mp_raceOverOutlineLbl;
       
       if ( !gameMgr->wasRaceAborted() ) {
//erase stats from the screen
              delete mp_timeLbl;
              delete mp_herringLbl;
              delete mp_scoreLbl;
              delete mp_maxspeedLbl;
              delete mp_flyingLbl;
              delete mp_resultsLbl;
              delete mp_highscoreLbl;

//erase stat outlines from the screen
              delete mp_timeOutlineLbl;
              delete mp_herringOutlineLbl;
              delete mp_scoreOutlineLbl;
              delete mp_maxspeedOutlineLbl;
              delete mp_flyingOutlineLbl;
              delete mp_resultsOutlineLbl;
              delete mp_highscoreOutlineLbl;
       }
}

Here is the call graph for this function:


Member Function Documentation

void GameMode::drawSnow ( float  timeStep,
bool  windy = false 
) [protected, inherited]

custom function for drawing snow in the ui

Definition at line 203 of file loop.cpp.

{
       // check wether ui snow is 
       if(getparam_ui_snow()){
              // update and draw snow
              update_ui_snow( timeStep, windy );
              draw_ui_snow();
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

virtual bool GameMode::keyboardEvent ( SDLKey  key,
bool  release 
) [inline, virtual, inherited]

Reimplemented in Racing.

Definition at line 90 of file loop.h.

{return false;};
bool GameOver::keyPressEvent ( SDLKey  key) [virtual]

Reimplemented from GameMode.

Definition at line 322 of file game_over.cpp.

Here is the call graph for this function:

virtual bool GameMode::keyReleaseEvent ( SDLKey  key) [inline, virtual, inherited]

Reimplemented in HighscoreShow, and SplashScreen.

Definition at line 92 of file loop.h.

{return false;};
void GameOver::loop ( float  timeStep) [virtual]

Implements GameMode.

Definition at line 245 of file game_over.cpp.

{
    int width, height;
    width = getparam_x_resolution();
    height = getparam_y_resolution();

    /* Check joystick */
    if ( is_joystick_active() ) {
       update_joystick();

       if ( is_joystick_continue_button_down() )
       {
           if ( gameMgr->gametype != GameMgr::PRACTICING ) {
                     set_game_mode( EVENT_RACE_SELECT );
              }else{
                     set_game_mode( RACE_SELECT );
              }
           winsys_post_redisplay();
           return;
       }
    }
    fpsCounter.update();

    update_audio();

    clear_rendering_context();

    fogPlane.setup();
    update_player_pos( players[0], 0 );
    update_view( players[0], 0 );

    setup_view_frustum( players[0], NEAR_CLIP_DIST, 
                     getparam_forward_clip_distance() );

    draw_sky(players[0].view.pos);
    draw_fog_plane();

    set_course_clipping( true );
    set_course_eye_point( players[0].view.pos );
    setup_course_lighting();
    render_course();
    //Draw snow
    if(gameMgr->getCurrentRace().snowing) {
        draw_snow(players[0].view.pos);
    }
    draw_trees();
    if ( getparam_draw_particles() ) {
              draw_particles( players[0] );
    }

    ModelHndl->draw_tux();
    draw_tux_shadow();
    set_gl_options( GUI );

    UIMgr.setupDisplay();
       UIMgr.draw();
              
    HUD1.draw(players[0]);
    reshape( width, height );

    winsys_swap_buffers();
}

Here is the call graph for this function:

bool GameOver::mouseButtonEvent ( int  button,
int  x,
int  y,
bool  pressed 
) [virtual]

Reimplemented from GameMode.

Definition at line 309 of file game_over.cpp.

Here is the call graph for this function:

virtual bool GameMode::mouseButtonPressEvent ( int  button,
int  x,
int  y 
) [inline, virtual, inherited]

Definition at line 95 of file loop.h.

{return false;};
virtual bool GameMode::mouseButtonReleaseEvent ( int  button,
int  x,
int  y 
) [inline, virtual, inherited]

Reimplemented in CreditsTrans, and SplashScreen.

Definition at line 96 of file loop.h.

{return false;};

Member Data Documentation

GameMode * GameMode::currentMode = NULL [static, inherited]

Definition at line 96 of file loop.h.

bool GameOver::m_aborted [private]

Definition at line 30 of file game_over.h.

bool GameOver::m_bestScore [private]

Definition at line 31 of file game_over.h.

game_mode_t GameMode::mode [static, inherited]

Definition at line 99 of file loop.h.

Definition at line 40 of file game_over.h.

Definition at line 52 of file game_over.h.

Definition at line 37 of file game_over.h.

Definition at line 49 of file game_over.h.

Definition at line 41 of file game_over.h.

Definition at line 53 of file game_over.h.

Definition at line 39 of file game_over.h.

Definition at line 51 of file game_over.h.

Definition at line 34 of file game_over.h.

Definition at line 46 of file game_over.h.

Definition at line 43 of file game_over.h.

Definition at line 55 of file game_over.h.

Definition at line 38 of file game_over.h.

Definition at line 50 of file game_over.h.

Definition at line 36 of file game_over.h.

Definition at line 48 of file game_over.h.

game_mode_t GameMode::prevmode [static, inherited]

Definition at line 100 of file loop.h.


The documentation for this class was generated from the following files: