Cleaned up explosion code (only cosmetic changes).
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@9599 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
c0fbf21f8a
commit
edfccbea30
@ -32,10 +32,13 @@
|
|||||||
|
|
||||||
const float burst_time = 0.1f;
|
const float burst_time = 0.1f;
|
||||||
|
|
||||||
Explosion::Explosion(const Vec3& coord, const char* explosion_sound, bool player_kart_hit)
|
/** Creates an explosion effect. */
|
||||||
|
Explosion::Explosion(const Vec3& coord, const char* explosion_sound,
|
||||||
|
bool player_kart_hit)
|
||||||
{
|
{
|
||||||
m_remaining_time = burst_time; // short emision time, explosion, not constant flame
|
// short emision time, explosion, not constant flame
|
||||||
m_node = irr_driver->addParticleNode();
|
m_remaining_time = burst_time;
|
||||||
|
m_node = irr_driver->addParticleNode();
|
||||||
m_player_kart_hit = player_kart_hit;
|
m_player_kart_hit = player_kart_hit;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
@ -47,40 +50,44 @@ Explosion::Explosion(const Vec3& coord, const char* explosion_sound, bool player
|
|||||||
m->setMaterialProperties(&(m_node->getMaterial(0)));
|
m->setMaterialProperties(&(m_node->getMaterial(0)));
|
||||||
m_node->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR );
|
m_node->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR );
|
||||||
|
|
||||||
scene::IParticleEmitter* em = m_node->createSphereEmitter(core::vector3df(0.0f,0.0f,0.0f), 0.5f,
|
scene::IParticleEmitter* em =
|
||||||
core::vector3df(0.0f,0.005f,0.0f), // velocity in m/ms
|
m_node->createSphereEmitter(core::vector3df(0.0f,0.0f,0.0f), 0.5f,
|
||||||
600, 900, // min max particles per sec
|
/* velocity in m/ms */core::vector3df(0.0f,0.005f,0.0f),
|
||||||
video::SColor(0, 0, 0, 0), video::SColor(0, 0, 0, 0), // min max colour
|
600, 900, // min max particles per sec
|
||||||
(int)((burst_time + explosion_time)*1000.0f),
|
video::SColor(0, 0, 0, 0), // min colour
|
||||||
(int)((burst_time + explosion_time)*1000.0f), // min max life ms
|
video::SColor(0, 0, 0, 0), // max colour
|
||||||
90, // max angle
|
(int)((burst_time + explosion_time)
|
||||||
core::dimension2df(0.3f, 0.3f), core::dimension2df(0.75f, 0.75f) // min max start size
|
*1000.0f), // min life ms
|
||||||
);
|
(int)((burst_time + explosion_time)
|
||||||
|
*1000.0f), // max max life ms
|
||||||
|
90, // max angle
|
||||||
|
// min and max start size
|
||||||
|
core::dimension2df(0.3f, 0.3f),
|
||||||
|
core::dimension2df(0.75f, 0.75f)
|
||||||
|
);
|
||||||
m_node->setEmitter(em); // this grabs the emitter
|
m_node->setEmitter(em); // this grabs the emitter
|
||||||
em->drop(); // so we can drop it here without deleting it
|
em->drop(); // so we can drop it here without deleting it
|
||||||
|
|
||||||
/*
|
scene::IParticleAffector* scale_affector =
|
||||||
// doesn't work; instead we'll be doing it by hand below
|
m_node->createScaleParticleAffector(core::dimension2df(3.0f, 3.0f));
|
||||||
scene::IParticleAffector* fade_out_affector = m_node->createFadeOutParticleAffector(video::SColor(0, 0, 0, 0), 10000);
|
|
||||||
m_node->addAffector(fade_out_affector); // same goes for the affector
|
|
||||||
fade_out_affector->drop();
|
|
||||||
*/
|
|
||||||
|
|
||||||
scene::IParticleAffector* scale_affector = m_node->createScaleParticleAffector(core::dimension2df(3.0f, 3.0f));
|
|
||||||
m_node->addAffector(scale_affector); // same goes for the affector
|
m_node->addAffector(scale_affector); // same goes for the affector
|
||||||
scale_affector->drop();
|
scale_affector->drop();
|
||||||
|
|
||||||
//scene::IParticleAffector *paf =
|
|
||||||
// m_node->createGravityAffector(Vec3(0, 0, -5).toIrrVector());
|
|
||||||
//m_node->addAffector(paf);
|
|
||||||
//paf->drop();
|
|
||||||
|
|
||||||
|
|
||||||
m_explode_sound = sfx_manager->createSoundSource( explosion_sound );
|
m_explode_sound = sfx_manager->createSoundSource( explosion_sound );
|
||||||
init(coord);
|
m_explode_sound->position(coord);
|
||||||
|
|
||||||
|
// in multiplayer mode, sounds are NOT positional (because we have multiple listeners)
|
||||||
|
// so the sounds of all AIs are constantly heard. So reduce volume of sounds.
|
||||||
|
if (race_manager->getNumLocalPlayers() > 1)
|
||||||
|
m_explode_sound->volume(m_player_kart_hit ? 1.0f : 0.5f);
|
||||||
|
else
|
||||||
|
m_explode_sound->volume(1.0f);
|
||||||
|
m_explode_sound->play();
|
||||||
} // Explosion
|
} // Explosion
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
/** Destructor stops the explosion sfx from being played and frees its memory.
|
||||||
|
*/
|
||||||
Explosion::~Explosion()
|
Explosion::~Explosion()
|
||||||
{
|
{
|
||||||
if (m_explode_sound->getStatus() == SFXManager::SFX_PLAYING)
|
if (m_explode_sound->getStatus() == SFXManager::SFX_PLAYING)
|
||||||
@ -89,26 +96,12 @@ Explosion::~Explosion()
|
|||||||
}
|
}
|
||||||
|
|
||||||
sfx_manager->deleteSFX(m_explode_sound);
|
sfx_manager->deleteSFX(m_explode_sound);
|
||||||
}
|
} // ~Explosion
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
void Explosion::init(const Vec3& coord)
|
|
||||||
{
|
|
||||||
m_explode_sound->position(coord);
|
|
||||||
|
|
||||||
// in multiplayer mode, sounds are NOT positional (because we have multiple listeners)
|
|
||||||
// so the sounds of all AIs are constantly heard. So reduce volume of sounds.
|
|
||||||
if (race_manager->getNumLocalPlayers() > 1)
|
|
||||||
{
|
|
||||||
m_explode_sound->volume(m_player_kart_hit ? 1.0f : 0.5f);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_explode_sound->volume(1.0f);
|
|
||||||
}
|
|
||||||
m_explode_sound->play();
|
|
||||||
} // init
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
/** Updates the explosion, called one per time step.
|
||||||
|
* \param dt Time step size.
|
||||||
|
*/
|
||||||
void Explosion::update(float dt)
|
void Explosion::update(float dt)
|
||||||
{
|
{
|
||||||
m_remaining_time -= dt;
|
m_remaining_time -= dt;
|
||||||
@ -157,4 +150,4 @@ void Explosion::update(float dt)
|
|||||||
projectile_manager->FinishedExplosion();
|
projectile_manager->FinishedExplosion();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
} // update
|
||||||
|
@ -47,7 +47,6 @@ private:
|
|||||||
public:
|
public:
|
||||||
Explosion(const Vec3& coord, const char* explosion_sound, bool player_hit);
|
Explosion(const Vec3& coord, const char* explosion_sound, bool player_hit);
|
||||||
~Explosion();
|
~Explosion();
|
||||||
void init (const Vec3& coord);
|
|
||||||
void update (float delta_t);
|
void update (float delta_t);
|
||||||
int inUse ();
|
int inUse ();
|
||||||
bool hasEnded () { return m_remaining_time <= -explosion_time; }
|
bool hasEnded () { return m_remaining_time <= -explosion_time; }
|
||||||
|
Loading…
Reference in New Issue
Block a user