Implementation of a simple gear box.

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@1210 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
hansthefarmer 2007-08-18 14:26:11 +00:00
parent f0288dd697
commit b476486fb0
2 changed files with 27 additions and 2 deletions

View File

@ -567,6 +567,30 @@ void Kart::doZipperProcessing (float delta)
else m_zipper_time_left = 0.0f ;
} // doZipperProcessing
#ifdef BULLET
//-----------------------------------------------------------------------------
float Kart::getActualWheelForce()
{
if ( m_speed <= m_max_speed*0.25f )
{
return( getMaxPower() * 2.5f ); // gear 1
}
else if ( m_speed > m_max_speed*0.25f && m_speed <= m_max_speed*0.5f )
{
return( getMaxPower() * 1.8f ); // gear 2
}
else if ( m_speed > m_max_speed*0.5f && m_speed <= m_max_speed*0.75f )
{
return( getMaxPower() * 1.4f ); // gear 3
}
else if ( m_speed > m_max_speed*0.75f )
{
return( getMaxPower() ); // gear 4
}
return(0.0f);
}
#endif
//-----------------------------------------------------------------------------
void Kart::getsProjectile ()
{
@ -870,7 +894,7 @@ void Kart::updatePhysics (float dt)
{
#ifdef BULLET
float engine_power = getMaxPower() + handleWheelie(dt);
float engine_power = getActualWheelForce() + handleWheelie(dt);
if(m_attachment.getType()==ATTACH_PARACHUTE) engine_power*=0.2;
if(m_controls.accel)
@ -943,7 +967,7 @@ void Kart::updatePhysics (float dt)
}
//at low velocity, forces on kart push it back and forth so we ignore this
if(fabsf(m_speed) < 0.13f)
if(fabsf(m_speed) < 0.2f) // quick'n'dirty workaround for bug 1776883
m_speed = 0;
#else // ! BULLET

View File

@ -240,6 +240,7 @@ public:
//have to use this instead of moveable getVelocity to get velocity for bullet rigid body
float getSpeed () const {return m_speed; }
float handleWheelie(float dt);
float getActualWheelForce();
#endif
void adjustSpeedWeight(float f);
void forceRescue ();