Delay start for 3s when intro sound is off

To bridge the silence before ready-set-go, the engines are started earlier than normal if intro sound is off.
This commit is contained in:
Antonius Riha 2016-05-02 21:53:34 +02:00
parent d4f1f28070
commit 342b4f299e
2 changed files with 28 additions and 4 deletions

View File

@ -30,6 +30,21 @@
#include <irrlicht.h>
//-----------------------------------------------------------------------------
/** Starts the kart engines.
*/
void WorldStatus::startEngines()
{
if (m_engines_started)
return;
m_engines_started = true;
for (unsigned int i = 0; i < World::getWorld()->getNumKarts(); i++)
{
World::getWorld()->getKart(i)->startEngineSFX();
}
}
//-----------------------------------------------------------------------------
WorldStatus::WorldStatus()
{
@ -55,6 +70,9 @@ void WorldStatus::reset()
{
m_time = 0.0f;
m_auxiliary_timer = 0.0f;
m_engines_started = false;
// Using SETUP_PHASE will play the track into sfx first, and has no
// other side effects.
m_phase = UserConfigParams::m_race_now ? MUSIC_PHASE : SETUP_PHASE;
@ -185,6 +203,13 @@ void WorldStatus::update(const float dt)
if (!UserConfigParams::m_sfx && m_auxiliary_timer < 3.0f)
return;
if (!m_play_track_intro_sound)
{
startEngines();
if (m_auxiliary_timer < 3.0f)
return;
}
m_auxiliary_timer = 0.0f;
if (m_play_ready_set_go_sounds)
@ -192,10 +217,7 @@ void WorldStatus::update(const float dt)
m_phase = READY_PHASE;
for (unsigned int i = 0; i < World::getWorld()->getNumKarts(); i++)
{
World::getWorld()->getKart(i)->startEngineSFX();
}
startEngines();
break;
case READY_PHASE:

View File

@ -114,6 +114,8 @@ private:
*/
float m_auxiliary_timer;
bool m_engines_started;
void startEngines();
public:
WorldStatus();
virtual ~WorldStatus();