Added intro sfx to be played before ready-set-go.
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@5663 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
862e5f6310
commit
396db5ae2b
@ -135,7 +135,10 @@ void MusicManager::addMusicToTracks()
|
||||
void MusicManager::startMusic(MusicInformation* mi)
|
||||
{
|
||||
// If this music is already playing, ignore this call.
|
||||
if (m_current_music != NULL && m_current_music == mi && m_current_music->isPlaying()) return;
|
||||
if (m_current_music != NULL &&
|
||||
m_current_music == mi &&
|
||||
m_current_music->isPlaying())
|
||||
return;
|
||||
|
||||
// It is possible here that startMusic() will be called without first calling stopMusic().
|
||||
// This would cause a memory leak by overwriting m_current_music without first releasing its resources.
|
||||
|
@ -412,6 +412,7 @@ bool UserConfig::loadConfig()
|
||||
if(!root || root->getName() != "stkconfig")
|
||||
{
|
||||
std::cerr << "Could not read user config file file " << filename.c_str() << std::endl;
|
||||
if(root) delete root;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -264,14 +264,20 @@ void Kart::createPhysics()
|
||||
m_uprightConstraint->setDamping(0.0f);
|
||||
World::getWorld()->getPhysics()->addKart(this);
|
||||
|
||||
//create the engine sound
|
||||
} // createPhysics
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Starts the engine sound effect. Called once the track intro phase is over.
|
||||
*/
|
||||
void Kart::startEngineSFX()
|
||||
{
|
||||
if(m_engine_sound)
|
||||
{
|
||||
m_engine_sound->speed(0.6f);
|
||||
m_engine_sound->setLoop(true);
|
||||
m_engine_sound->play();
|
||||
}
|
||||
} // createPhysics
|
||||
} // startEngineSFX
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** The destructor frees the memory of this kart, but note that the actual kart
|
||||
@ -413,6 +419,8 @@ void Kart::reset()
|
||||
{
|
||||
sfx_manager->deleteSFX(m_previous_terrain_sound);
|
||||
}
|
||||
if(m_engine_sound)
|
||||
m_engine_sound->stop();
|
||||
|
||||
m_controls.m_steer = 0.0f;
|
||||
m_controls.m_accel = 0.0f;
|
||||
|
@ -367,6 +367,7 @@ public:
|
||||
bool isEliminated () const {return m_eliminated;}
|
||||
void eliminate ();
|
||||
void resetBrakes ();
|
||||
void startEngineSFX ();
|
||||
void adjustSpeed (float f);
|
||||
void updatedWeight ();
|
||||
/** Returns a name to be displayed for this kart. */
|
||||
|
@ -147,7 +147,6 @@ void World::init()
|
||||
// objects need to allocate data structures depending on the number
|
||||
// of karts.
|
||||
m_track->reset();
|
||||
m_track->startMusic();
|
||||
|
||||
if(!history->replayHistory()) history->initRecording();
|
||||
network_manager->worldLoaded();
|
||||
@ -645,7 +644,6 @@ void World::restartRace()
|
||||
// Start music from beginning
|
||||
music_manager->stopMusic();
|
||||
m_track->reset();
|
||||
m_track->startMusic();
|
||||
|
||||
// Enable SFX again
|
||||
sfx_manager->resumeAll();
|
||||
|
@ -17,25 +17,30 @@
|
||||
|
||||
#include "modes/world_status.hpp"
|
||||
|
||||
#include "audio/music_manager.hpp"
|
||||
#include "audio/sfx_manager.hpp"
|
||||
#include "audio/sfx_base.hpp"
|
||||
#include "config/stk_config.hpp"
|
||||
#include "guiengine/modaldialog.hpp"
|
||||
#include "modes/world.hpp"
|
||||
#include "tracks/track.hpp"
|
||||
#include "network/network_manager.hpp"
|
||||
#include "states_screens/dialogs/race_over_dialog.hpp"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
WorldStatus::WorldStatus()
|
||||
{
|
||||
m_clock_mode = CLOCK_CHRONO;
|
||||
m_time = 0.0f;
|
||||
m_auxiliary_timer = 0.0f;
|
||||
m_phase = SETUP_PHASE;
|
||||
m_previous_phase = UNDEFINED_PHASE; // initialise it just in case
|
||||
m_clock_mode = CLOCK_CHRONO;
|
||||
m_time = 0.0f;
|
||||
m_auxiliary_timer = 0.0f;
|
||||
m_phase = SETUP_PHASE;
|
||||
m_previous_phase = UNDEFINED_PHASE; // initialise it just in case
|
||||
|
||||
// FIXME - is it a really good idea to reload and delete the sound every race??
|
||||
m_prestart_sound = sfx_manager->createSoundSource("prestart");
|
||||
m_start_sound = sfx_manager->createSoundSource("start");
|
||||
m_prestart_sound = sfx_manager->createSoundSource("prestart");
|
||||
m_start_sound = sfx_manager->createSoundSource("start");
|
||||
m_track_intro_sound = sfx_manager->createSoundSource("track_intro");
|
||||
|
||||
music_manager->stopMusic();
|
||||
} // WorldStatus
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -45,8 +50,12 @@ void WorldStatus::reset()
|
||||
{
|
||||
m_time = 0.0f;
|
||||
m_auxiliary_timer = 0.0f;
|
||||
m_phase = READY_PHASE; // FIXME - unsure
|
||||
// Using SETUP_PHASE will play the track into sfx first, and has no
|
||||
// other side effects.
|
||||
m_phase = SETUP_PHASE;
|
||||
m_previous_phase = UNDEFINED_PHASE;
|
||||
// Just in case that the game is reset during the intro phase
|
||||
m_track_intro_sound->stop();
|
||||
} // reset
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -112,14 +121,23 @@ void WorldStatus::update(const float dt)
|
||||
// simplifies this handling
|
||||
case SETUP_PHASE:
|
||||
m_auxiliary_timer = 0.0f;
|
||||
m_phase = READY_PHASE;
|
||||
m_phase = TRACK_INTRO_PHASE;
|
||||
m_track_intro_sound->play();
|
||||
return;
|
||||
case TRACK_INTRO_PHASE:
|
||||
if(m_track_intro_sound->getStatus()==SFXManager::SFX_PLAYING)
|
||||
return;
|
||||
m_prestart_sound->play();
|
||||
return; // loading time, don't play sound yet
|
||||
m_phase = READY_PHASE;
|
||||
for(unsigned int i=0; i<World::getWorld()->getNumKarts(); i++)
|
||||
World::getWorld()->getKart(i)->startEngineSFX();
|
||||
|
||||
break;
|
||||
case READY_PHASE:
|
||||
if(m_auxiliary_timer>1.0)
|
||||
{
|
||||
m_phase=SET_PHASE;
|
||||
m_prestart_sound->play();
|
||||
m_phase=SET_PHASE;
|
||||
}
|
||||
m_auxiliary_timer += dt;
|
||||
return;
|
||||
@ -127,8 +145,7 @@ void WorldStatus::update(const float dt)
|
||||
if(m_auxiliary_timer>2.0)
|
||||
{
|
||||
// set phase is over, go to the next one
|
||||
m_phase=GO_PHASE;
|
||||
|
||||
m_phase=GO_PHASE;
|
||||
m_start_sound->play();
|
||||
|
||||
// event
|
||||
@ -137,7 +154,9 @@ void WorldStatus::update(const float dt)
|
||||
m_auxiliary_timer += dt;
|
||||
return;
|
||||
case GO_PHASE :
|
||||
if(m_auxiliary_timer>3.0) // how long to display the 'go' message
|
||||
if(m_auxiliary_timer>2.5f)
|
||||
World::getWorld()->getTrack()->startMusic();
|
||||
if(m_auxiliary_timer>3.0f) // how long to display the 'go' message
|
||||
m_phase=MUSIC_PHASE;
|
||||
m_auxiliary_timer += dt;
|
||||
break;
|
||||
|
@ -37,6 +37,9 @@ public:
|
||||
};
|
||||
|
||||
enum Phase {
|
||||
// Time for a camera movement, and introductory song
|
||||
TRACK_INTRO_PHASE,
|
||||
|
||||
// Game setup, e.g. track loading
|
||||
SETUP_PHASE,
|
||||
|
||||
@ -75,7 +78,12 @@ public:
|
||||
UNDEFINED_PHASE
|
||||
};
|
||||
protected:
|
||||
/** Sound to play at the beginning of a race, during which a
|
||||
* a camera intro of the track can be shown. */
|
||||
SFXBase *m_track_intro_sound;
|
||||
/** Sound used for the first two 'beeps' in ready, set, go. */
|
||||
SFXBase *m_prestart_sound;
|
||||
/** The third sound to be played in ready, set, go. */
|
||||
SFXBase *m_start_sound;
|
||||
|
||||
/**
|
||||
|
@ -46,18 +46,20 @@ private:
|
||||
public:
|
||||
static const int QUAD_NONE=-1;
|
||||
|
||||
QuadSet (const std::string& filename);
|
||||
const Quad& getQuad(int n) const {return *(m_all_quads[n]); }
|
||||
int getCurrentQuad(const Vec3& p, int oldQuad) const;
|
||||
QuadSet (const std::string& filename);
|
||||
int getCurrentQuad(const Vec3& p, int oldQuad) const;
|
||||
const Quad& getQuad(int n) const {return *(m_all_quads[n]); }
|
||||
|
||||
/** Return the minimum and maximum coordinates of this quad set. */
|
||||
void getBoundingBox(Vec3 *min, Vec3 *max) { *min=m_min; *max=m_max; }
|
||||
void getBoundingBox(Vec3 *min, Vec3 *max)
|
||||
{ *min=m_min; *max=m_max; }
|
||||
/** Returns the number of quads. */
|
||||
unsigned int getNumberOfQuads() const
|
||||
{return (unsigned int)m_all_quads.size(); }
|
||||
/** Returns the center of quad n. */
|
||||
const Vec3& getCenterOfQuad(int n) const
|
||||
const Vec3& getCenterOfQuad(int n) const
|
||||
{return m_all_quads[n]->getCenter(); }
|
||||
/** Returns the n-th. quad. */
|
||||
const Quad& getQuad(int n) {return *(m_all_quads[n]); }
|
||||
const Quad& getQuad(int n) {return *(m_all_quads[n]); }
|
||||
}; // QuadSet
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user