Back to index

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

#include <reset.h>

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

List of all members.

Public Member Functions

 Reset ()
 ~Reset ()
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 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

const pp::Color m_textColor
double m_resetStartTime
bool m_positionReset

Detailed Description

Definition at line 30 of file reset.h.


Constructor & Destructor Documentation

Definition at line 54 of file reset.cpp.

 : m_textColor(0.0, 0.0, 0.0),
   m_resetStartTime(getClockTime()),
   m_positionReset(false)
{
}

Definition at line 61 of file reset.cpp.

{
       
}

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;};
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 Reset::loop ( float  timeStep) [virtual]

Implements GameMode.

Definition at line 67 of file reset.cpp.

{
       int width, height;
    float elapsed_time = getClockTime() - m_resetStartTime;
    float course_width, course_length;
    static bool tux_visible = true; 
    static int tux_visible_count = 0;
    item_type_t  *item_types;
    Item       *item_locs;
    int  i, first_reset, last_reset, num_item_types;
    int best_loc;

    width = getparam_x_resolution();
    height = getparam_y_resolution();

    fpsCounter.update();

    update_audio();

    clear_rendering_context();

    fogPlane.setup();

    update_player_pos( players[0], EPS );
       
    update_view( players[0], EPS );

    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_trees();

    if ((elapsed_time > BLINK_IN_PLACE_TIME) && (!m_positionReset)) {
       item_types = get_item_types();
       item_locs  = get_item_locs();
       num_item_types = get_num_item_types();
       first_reset = 0;
       last_reset = 0;
       for ( i = 0; i < num_item_types; i++ ) {
           if (item_types[i].reset_point == true) {
              last_reset = first_reset + item_types[i].num_items - 1;
              break;
           } else {
              first_reset += item_types[i].num_items;
           }
       }

       if (last_reset == 0) {
           // didn't find a reset point item type 
           get_course_dimensions( &course_width, &course_length );
           players[0].pos.x = course_width/2.0;
           players[0].pos.z = MIN(players[0].pos.z + 10, -1.0);
       } else {
           // BFI 
           best_loc = -1;
           for ( i = first_reset; i <= last_reset; i++) {
              if (item_locs[i].ray.pt.z > players[0].pos.z ) { 
                  if (best_loc == -1 || 
                     item_locs[i].ray.pt.z < item_locs[best_loc].ray.pt.z)
                  {
                     best_loc = i;
                  }
              }
           }

           if ( best_loc == -1 ) {
              get_course_dimensions( &course_width, &course_length );
              players[0].pos.x = course_width/2.0;
              players[0].pos.z = MIN(players[0].pos.z + 10, -1.0);
           } else if ( item_locs[best_loc].ray.pt.z <= players[0].pos.z ) {
              get_course_dimensions( &course_width, &course_length );
              players[0].pos.x = course_width/2.0;
              players[0].pos.z = MIN(players[0].pos.z + 10, -1.0);
           } else {
              players[0].pos.x = item_locs[best_loc].ray.pt.x;
              players[0].pos.z = item_locs[best_loc].ray.pt.z;
           }
       }

       // Re-initialize the camera 
       players[0].view.initialized = false;

       init_physical_simulation();
       m_positionReset = true;
    }

    if (tux_visible) { 
       ModelHndl->draw_tux();
       draw_tux_shadow();
    } 
    if (++tux_visible_count > 3) {
       tux_visible = (bool) !tux_visible;
       tux_visible_count = 0;
    }

    HUD1.draw(players[0]);

    reshape( width, height );

    winsys_swap_buffers();

    gameMgr->time += timeStep;

    if (elapsed_time > TOTAL_RESET_TIME) {
              set_game_mode( RACING );
              winsys_post_redisplay();
    }  
}

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;};

Member Data Documentation

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

Definition at line 96 of file loop.h.

bool Reset::m_positionReset [private]

Definition at line 34 of file reset.h.

double Reset::m_resetStartTime [private]

Definition at line 33 of file reset.h.

const pp::Color Reset::m_textColor [private]

Definition at line 32 of file reset.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.


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