Made m_phase and m_auxiliary_timer private, and added

setPhase. Removed usage of auxiliary timer in overworld
(instead set phase to race_phase) - as a result there
is no mpre 'Go!' being displayed (which I think is
actually better for the overworld).


git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@11225 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
hikerstk 2012-05-10 12:57:45 +00:00
parent 81691b00c0
commit a526fef588
5 changed files with 48 additions and 38 deletions

View File

@ -112,12 +112,11 @@ void OverWorld::update(float dt)
// Skip annoying waiting without a purpose // Skip annoying waiting without a purpose
// Make sure to do all things that would normally happen in the // Make sure to do all things that would normally happen in the
// update() method of the base classes. // update() method of the base classes.
if (m_phase < GO_PHASE) if (getPhase()< GO_PHASE)
{ {
m_phase = GO_PHASE; setPhase(RACE_PHASE);
// Go message disappears at 3, music starts at 2.5 // Normally done in WorldStatus::update(), during phase SET_PHASE,
m_auxiliary_timer = 2.0f; // so we have to start music 'manually', since we skip all phases.
// Normally done in WorldStatus::update(), SET_PHASE
World::getWorld()->getTrack()->startMusic(); World::getWorld()->getTrack()->startMusic();
} }
LinearWorld::update(dt); LinearWorld::update(dt);

View File

@ -43,7 +43,7 @@ ProfileWorld::ProfileWorld()
// based profiling) - in case of time based profiling, the number of // based profiling) - in case of time based profiling, the number of
// laps is set to 99999. // laps is set to 99999.
race_manager->setNumLaps(m_num_laps); race_manager->setNumLaps(m_num_laps);
m_phase = RACE_PHASE; setPhase(RACE_PHASE);
m_frame_count = 0; m_frame_count = 0;
m_start_time = irr_driver->getRealTime(); m_start_time = irr_driver->getRealTime();
m_num_triangles = 0; m_num_triangles = 0;

View File

@ -130,6 +130,6 @@ void StandardRace::endRaceEarly()
); );
} // Finish the active players } // Finish the active players
endSetKartPositions(); endSetKartPositions();
m_phase = RESULT_DISPLAY_PHASE; setPhase(RESULT_DISPLAY_PHASE);
terminateRace(); terminateRace();
} // endRaceEarly } // endRaceEarly

View File

@ -607,8 +607,8 @@ void World::updateWorld(float dt)
} }
// Don't update world if a menu is shown or the race is over. // Don't update world if a menu is shown or the race is over.
if( m_phase == FINISH_PHASE || if( getPhase() == FINISH_PHASE ||
m_phase == IN_GAME_MENU_PHASE ) getPhase() == IN_GAME_MENU_PHASE )
return; return;
update(dt); update(dt);

View File

@ -91,7 +91,8 @@ protected:
*/ */
float m_time; float m_time;
ClockType m_clock_mode; ClockType m_clock_mode;
private:
Phase m_phase; Phase m_phase;
/** /**
@ -110,43 +111,53 @@ public:
virtual ~WorldStatus(); virtual ~WorldStatus();
void reset(); void reset();
void update(const float dt);
// Note: GO_PHASE is both: start phase and race phase void setTime(const float time);
bool isStartPhase() const { return m_phase<GO_PHASE; }
bool isRacePhase() const { return m_phase>=GO_PHASE &&
m_phase<FINISH_PHASE; }
/** While the race menu is being displayed, m_phase is limbo, and
* m_previous_phase is finish. So we have to test this case, too. */
bool isFinishPhase() const { return m_phase==FINISH_PHASE ||
(m_phase==IN_GAME_MENU_PHASE &&
m_previous_phase==FINISH_PHASE);}
const Phase getPhase() const { return m_phase; }
/** Call to specify what kind of clock you want. The second argument
* can be used to specify the initial time value (especially useful
* for countdowns). */
void setClockMode(const ClockType mode, const float initial_time=0.0f);
/** Returns the current clock mode. */
int getClockMode() const { return m_clock_mode; }
/** Returns the current race time. */
float getTime() const { return m_time; }
/** Call each frame, with the elapsed time as argument. */
void update(const float dt);
void setTime(const float time);
virtual void pause(Phase phase); virtual void pause(Phase phase);
virtual void unpause(); virtual void unpause();
virtual void enterRaceOverState(); virtual void enterRaceOverState();
virtual void terminateRace(); virtual void terminateRace();
// ------------------------------------------------------------------------
// Note: GO_PHASE is both: start phase and race phase
bool isStartPhase() const { return m_phase<GO_PHASE; }
// ------------------------------------------------------------------------
bool isRacePhase() const { return m_phase>=GO_PHASE &&
m_phase<FINISH_PHASE; }
// ------------------------------------------------------------------------
/** While the race menu is being displayed, m_phase is limbo, and
* m_previous_phase is finish. So we have to test this case, too. */
bool isFinishPhase() const { return m_phase==FINISH_PHASE ||
(m_phase==IN_GAME_MENU_PHASE &&
m_previous_phase==FINISH_PHASE);}
// ------------------------------------------------------------------------
/** Returns the current race phase. */
const Phase getPhase() const { return m_phase; }
// ------------------------------------------------------------------------
/** Sets the current race phase. Canbe used to e.g. avoid the count down
* etc. */
void setPhase(Phase phase) { m_phase = phase; }
// ------------------------------------------------------------------------
/** Call to specify what kind of clock you want. The second argument
* can be used to specify the initial time value (especially useful
* for countdowns). */
void setClockMode(const ClockType mode, const float initial_time=0.0f);
// ------------------------------------------------------------------------
/** Returns the current clock mode. */
int getClockMode() const { return m_clock_mode; }
// ------------------------------------------------------------------------
/** Returns the current race time. */
float getTime() const { return m_time; }
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
/** Will be called to notify your derived class that the clock, /** Will be called to notify your derived class that the clock,
* which is in COUNTDOWN mode, has reached zero. */ * which is in COUNTDOWN mode, has reached zero. */
virtual void countdownReachedZero() {}; virtual void countdownReachedZero() {};
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
/** Called when the race actually starts. */ /** Called when the race actually starts. */
virtual void onGo() {}; virtual void onGo() {};