Back to index

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

#include <bench.h>

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

List of all members.

Public Types

enum  mode_t { NONE = 0, AUTO = 1, DEMO, PAUSED }

Public Member Functions

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

Static Public Member Functions

static void setCourse (const char *course)
static void setMaxTime (double time)
static void setMaxFrames (int frames)
static void setPosition (pp::Vec2d &position)
static pp::Vec2dgetPosition ()
static Benchmark::mode_t getMode ()
static void setMode (Benchmark::mode_t)
static void setTimeStep (double timeStep)
static double getTimeStep ()
static void setRaceCondition (int condition)
static void updateFPS (double fps)
static void displayState ()

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

Static Private Attributes

static std::string sm_course
static double sm_frames = 0.0
static double sm_oldFrames = 0.0
static int sm_framesCounter = 0
static int sm_maxFrames = 0
static int sm_fc = 0
static pp::Vec2d sm_pos
static double sm_timeStep = -1
static race_conditions_t sm_condition = RACE_CONDITIONS_SUNNY
static mode_t sm_mode = Benchmark::NONE

Detailed Description

Definition at line 31 of file bench.h.


Member Enumeration Documentation

Enumerator:
NONE 
AUTO 
DEMO 
PAUSED 

Definition at line 49 of file bench.h.

                   {
              NONE=0,
              AUTO=1,
              DEMO,
              PAUSED        
       }mode_t;

Constructor & Destructor Documentation

Definition at line 36 of file bench.cpp.

{
       
       
}

Definition at line 42 of file bench.cpp.

{
              
       
}

Member Function Documentation

void Benchmark::displayState ( ) [static]

Definition at line 155 of file bench.cpp.

{
       std::cout << std::endl;
       std::cout << "Frames: "
                     << sm_frames << std::endl;
       
       std::cout << "Average FPS: "
                     << sm_frames/sm_framesCounter << std::endl;
}

Here is the caller graph for this function:

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:

Definition at line 108 of file bench.cpp.

{
       return sm_mode;
}

Here is the caller graph for this function:

Definition at line 96 of file bench.cpp.

{
       return sm_pos;
}

Here is the caller graph for this function:

double Benchmark::getTimeStep ( ) [static]

Definition at line 120 of file bench.cpp.

{
       return sm_timeStep;
}

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;};
virtual bool GameMode::keyPressEvent ( SDLKey  key) [inline, virtual, inherited]

Reimplemented in EventSelect, EventRaceSelect, RaceSelect, GameOver, CreditsTrans, ConfigMode, Racing, GameTypeSelect, Paused, Credits, and Intro.

Definition at line 91 of file loop.h.

{return false;};
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 Benchmark::loop ( float  timeStep) [virtual]

Implements GameMode.

Definition at line 49 of file bench.cpp.

{
       static std::list<CourseData>::iterator it;
       
       it = openCourseList.begin();

       for (it=openCourseList.begin(); 
              it != openCourseList.end();
              it++)
       {
              if((*it).course == sm_course) break;                    
       }
       
       if( it != openCourseList.end() ){
              gameMgr->setCurrentRace(it);
              gameMgr->getCurrentRace().condition = sm_condition;
       }else{
              std::cout << "Benchmark error: unable to set course: " 
                                   << sm_course << std::endl;
              exit(0);
       }
       
       set_game_mode( LOADING );
}

Here is the call graph for this function:

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

Reimplemented in GameOver.

Definition at line 94 of file loop.h.

{return false;};
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;};
void Benchmark::setCourse ( const char *  course) [static]

Definition at line 75 of file bench.cpp.

Here is the caller graph for this function:

void Benchmark::setMaxFrames ( int  frames) [static]

Definition at line 84 of file bench.cpp.

Here is the caller graph for this function:

static void Benchmark::setMaxTime ( double  time) [static]
void Benchmark::setMode ( Benchmark::mode_t  mode) [static]

Definition at line 102 of file bench.cpp.

{
       sm_mode = mode;
}

Here is the caller graph for this function:

void Benchmark::setPosition ( pp::Vec2d position) [static]

Definition at line 90 of file bench.cpp.

{
       sm_pos = position;
}

Here is the caller graph for this function:

void Benchmark::setRaceCondition ( int  condition) [static]

Definition at line 126 of file bench.cpp.

{
       if (condition > 0 && 
              condition < RACE_CONDITIONS_NUM_CONDITIONS)
       {
              sm_condition = (race_conditions_t) condition;
       }
}

Here is the caller graph for this function:

void Benchmark::setTimeStep ( double  timeStep) [static]

Definition at line 114 of file bench.cpp.

{
       sm_timeStep = timeStep;
}

Here is the caller graph for this function:

void Benchmark::updateFPS ( double  fps) [static]

Definition at line 136 of file bench.cpp.

{
       sm_frames+=fps;
       sm_framesCounter++;
       
       if(sm_fc>=2){
              sm_fc=0;
              std::cout << "FPS: "<< (sm_frames-sm_oldFrames)/3 << std::endl;
              sm_oldFrames = sm_frames;          
       }else{
              sm_fc++;
       }
              
       if( sm_maxFrames > 0 && sm_frames >= sm_maxFrames ){
              set_game_mode(GAME_OVER);          
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

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

Definition at line 96 of file loop.h.

game_mode_t GameMode::mode [static, inherited]

Definition at line 99 of file loop.h.

game_mode_t GameMode::prevmode [static, inherited]

Definition at line 100 of file loop.h.

Definition at line 41 of file bench.h.

std::string Benchmark::sm_course [static, private]

Definition at line 33 of file bench.h.

int Benchmark::sm_fc = 0 [static, private]

Definition at line 38 of file bench.h.

double Benchmark::sm_frames = 0.0 [static, private]

Definition at line 34 of file bench.h.

int Benchmark::sm_framesCounter = 0 [static, private]

Definition at line 36 of file bench.h.

int Benchmark::sm_maxFrames = 0 [static, private]

Definition at line 37 of file bench.h.

Definition at line 71 of file bench.h.

double Benchmark::sm_oldFrames = 0.0 [static, private]

Definition at line 35 of file bench.h.

pp::Vec2d Benchmark::sm_pos [static, private]

Definition at line 39 of file bench.h.

double Benchmark::sm_timeStep = -1 [static, private]

Definition at line 40 of file bench.h.


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