Now respecting rate in XML file for nitro (Kart was hardcoding rate...)+

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@7293 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria 2011-01-06 01:40:00 +00:00
parent b6b9f2810d
commit 2847f8527e
3 changed files with 10 additions and 3 deletions

View File

@ -12,8 +12,8 @@
<material file="nitro-particle.png" />
<!-- Amount of particles emitted per second -->
<rate min="5"
max="10" />
<rate min="130"
max="160" />
<!-- Minimal and maximal lifetime of a particle, in milliseconds. -->
<lifetime min="1000"

View File

@ -54,6 +54,8 @@ public:
void setCreationRate(float f);
void setPosition(core::vector3df pos);
ParticleKind* getParticlesInfo() { return m_particle_type; }
};
#endif

View File

@ -1584,8 +1584,13 @@ void Kart::updateGraphics(const Vec3& offset_xyz,
{
// fabs(speed) is important, otherwise the negative number will
// become a huge unsigned number in the particle scene node!
const float minRate = m_nitro->getParticlesInfo()->getMinRate();
const float maxRate = m_nitro->getParticlesInfo()->getMaxRate();
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
? (10.0f + fabsf(getSpeed())*20.0f) : 0);
? (minRate + rate*(maxRate - minRate)) : 0);
}
// For testing purposes mis-use the nitro graphical effects to show