Tweak fire on zippers to actually work. A side effect is that now when you use nitro and stop using it, instead of stopping immediately it fades out over a second or two. Tell me if you love or hate :)

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@9458 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria
2011-08-10 02:11:01 +00:00
parent 39e5d9ef53
commit ef7b491a0f
3 changed files with 13 additions and 3 deletions

View File

@@ -258,6 +258,13 @@ void ParticleEmitter::setCreationRate(float f)
}
} // setCreationRate
//-----------------------------------------------------------------------------
int ParticleEmitter::getCreationRate()
{
return m_emitter->getMinParticlesPerSecond();
}
//-----------------------------------------------------------------------------
/** Sets the position of the particle emitter.
* \param pos The position for the particle emitter.

View File

@@ -74,6 +74,7 @@ public:
virtual ~ParticleEmitter();
virtual void update ();
void setCreationRate(float f);
int getCreationRate();
void setPosition(const Vec3 &pos);

View File

@@ -1917,9 +1917,11 @@ void Kart::updateGraphics(float dt, const Vec3& offset_xyz,
const float rate = fabsf(getSpeed())/m_kart_properties->getMaxSpeed();
assert(rate >= 0.0f); // allow for rounding errors...
//assert(rate <= 2.0f); // max speed is not always respected it seems...
m_nitro->setCreationRate(m_controls.m_nitro && isOnGround() &&
m_collected_energy>0
? (min_rate + rate*(max_rate - min_rate)) : 0);
float calculated_rate = m_controls.m_nitro && isOnGround() && m_collected_energy > 0
? (min_rate + rate*(max_rate - min_rate)) : 0;
// the std::max call is there to let nitro fade out smoothly instead of stopping sharply
m_nitro->setCreationRate(std::max(calculated_rate, m_nitro->getCreationRate() - dt*800.0f));
// the emitter box should spread from last frame's position to the current position
// if we want nitro to be emitted in a smooth, continuous flame and not in blobs