Added last lap sfx, which is played once when the first kart

starts the last lap.


git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@5656 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
hikerstk
2010-07-06 00:11:42 +00:00
parent ee6284652c
commit 468e059a94
2 changed files with 24 additions and 4 deletions

View File

@@ -21,6 +21,8 @@
#include <sstream>
#include "audio/music_manager.hpp"
#include "audio/sfx_base.hpp"
#include "audio/sfx_manager.hpp"
#include "network/network_manager.hpp"
#include "race/history.hpp"
#include "tracks/track.hpp"
@@ -31,7 +33,9 @@
//-----------------------------------------------------------------------------
LinearWorld::LinearWorld() : World()
{
m_kart_display_info = NULL;
m_kart_display_info = NULL;
m_last_lap_sfx = sfx_manager->createSoundSource("lastlap");
m_last_lap_sfx_played = false;
} // LinearWorld
// ----------------------------------------------------------------------------
@@ -78,6 +82,8 @@ void LinearWorld::init()
//-----------------------------------------------------------------------------
LinearWorld::~LinearWorld()
{
sfx_manager->deleteSFX(m_last_lap_sfx);
// In case that a track is not found, m_kart_display info was never
// initialised.
if(m_kart_display_info)
@@ -258,6 +264,11 @@ void LinearWorld::newLap(unsigned int kart_index)
{
m_race_gui->addMessage(_("Final lap!"), m_karts[kart_index],
3.0f, 40, video::SColor(255, 210, 100, 50), true);
if(!m_last_lap_sfx_played)
{
m_last_lap_sfx->play();
m_last_lap_sfx_played = true;
}
}
// The race positions must be updated here: consider the situation where

View File

@@ -21,7 +21,10 @@
#include <vector>
#include "modes/world.hpp"
#include "states_screens/race_gui.hpp"
struct RaceGUI::KartIconDisplayInfo;
class SFXBase;
/*
* A 'linear world' is a subcategory of world used in 'standard' races, i.e.
* with a start line and a road that loops. This includes management of drivelines
@@ -30,6 +33,12 @@
*/
class LinearWorld : public World
{
/** Sfx for the final lap. */
SFXBase *m_last_lap_sfx;
/** Last lap sfx should only be played once. */
bool m_last_lap_sfx_played;
private:
/** Some additional info that needs to be kept for each kart
* in this kind of race.
@@ -48,9 +57,9 @@ private:
int m_last_valid_race_lap; /* when a kart is rescued, we need to give it back the number of lap it had */
Vec3 m_curr_track_coords;
/** True if the kart is on top of the road path drawn by the drivelines */
bool m_on_road;
bool m_on_road; // true if the kart is on top of the
// road path drawn by the drivelines
};
protected: