Added bounce sound effect for rubber balls. For now(!) this

is just reusing the race-start 'ping', so this needs to be
replaced with a better sfx!!


git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@9598 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
hikerstk 2011-08-21 21:56:49 +00:00
parent 720713b9a9
commit c0fbf21f8a
2 changed files with 24 additions and 0 deletions

View File

@ -19,6 +19,8 @@
#include "items/rubber_ball.hpp"
#include "audio/sfx_base.hpp"
#include "audio/sfx_manager.hpp"
#include "items/projectile_manager.hpp"
#include "karts/kart.hpp"
#include "modes/linear_world.hpp"
@ -64,8 +66,17 @@ RubberBall::RubberBall(Kart *kart)
m_timer = 0.0f;
m_interval = m_st_interval;
m_current_max_height = m_max_height;
m_ping_sfx = sfx_manager->createSoundSource("ball_bounce");
} // RubberBall
// -----------------------------------------------------------------------------
RubberBall::~RubberBall()
{
if(m_ping_sfx->getStatus()==SFXManager::SFX_PLAYING)
m_ping_sfx->stop();
sfx_manager->deleteSFX(m_ping_sfx);
} // ~RubberBall
// -----------------------------------------------------------------------------
/** Sets up the control points for the interpolation. The parameter contains
* the coordinates of the first control points (i.e. a control point that
@ -309,6 +320,11 @@ float RubberBall::updateHeight()
if(m_timer>m_interval)
{
m_timer -= m_interval;
if(m_ping_sfx->getStatus()!=SFXManager::SFX_PLAYING)
{
m_ping_sfx->position(getXYZ());
m_ping_sfx->play();
}
LinearWorld *world = dynamic_cast<LinearWorld*>(World::getWorld());
float target_distance =

View File

@ -25,6 +25,7 @@
class Kart;
class QuadGraph;
class SFXBase;
/**
* \ingroup items
@ -106,6 +107,12 @@ private:
* used to keep track of the state of this ball. */
bool m_aiming_at_target;
/** A 'ping' sound effect to be played when the ball hits the ground. */
SFXBase *m_ping_sfx;
/** Sound effect to be played when a ball hits a kart. */
SFXBase *m_hit_sfx;
void computeTarget();
void checkDistanceToTarget();
unsigned int getSuccessorToHitTarget(unsigned int node_index,
@ -116,6 +123,7 @@ private:
void initializeControlPoints(const Vec3 &xyz);
public:
RubberBall (Kart* kart);
virtual ~RubberBall();
static void init(const XMLNode &node, scene::IMesh *bowling);
virtual void update (float dt);
virtual void hit (Kart* kart, PhysicalObject* obj=NULL);