Added secret debug feature (hint : build in debug more and try keys JIK)
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@6334 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
7384002252
commit
8ea72b1fa3
@ -95,6 +95,24 @@ void InputManager::handleStaticAction(int key, int value)
|
||||
case KEY_LCONTROL:
|
||||
control_is_pressed = value!=0;
|
||||
break;
|
||||
case KEY_KEY_J:
|
||||
{
|
||||
Kart* kart = world->getLocalPlayerKart(0);
|
||||
kart->fly();
|
||||
break;
|
||||
}
|
||||
case KEY_KEY_I:
|
||||
{
|
||||
Kart* kart = world->getLocalPlayerKart(0);
|
||||
kart->flyUp();
|
||||
break;
|
||||
}
|
||||
case KEY_KEY_K:
|
||||
{
|
||||
Kart* kart = world->getLocalPlayerKart(0);
|
||||
kart->flyDown();
|
||||
break;
|
||||
}
|
||||
case KEY_F1:
|
||||
if (world && race_manager->getNumPlayers() ==1 )
|
||||
{
|
||||
|
@ -96,6 +96,7 @@ Kart::Kart (const std::string& ident, int position,
|
||||
m_camera = NULL;
|
||||
m_controller = NULL;
|
||||
m_saved_controller = NULL;
|
||||
m_flying = false;
|
||||
|
||||
m_view_blocked_by_plunger = 0;
|
||||
|
||||
@ -267,6 +268,13 @@ void Kart::createPhysics()
|
||||
|
||||
} // createPhysics
|
||||
|
||||
void Kart::fly()
|
||||
{
|
||||
m_flying = true;
|
||||
Moveable::fly();
|
||||
//m_vehicle->m_flying = true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Starts the engine sound effect. Called once the track intro phase is over.
|
||||
*/
|
||||
@ -663,13 +671,16 @@ void Kart::update(float dt)
|
||||
m_controls.m_fire = false;
|
||||
}
|
||||
|
||||
// When really on air, free fly, when near ground, try to glide / adjust for landing
|
||||
// If zipped, be stable, so ramp+zipper can allow nice jumps without scripting the fly
|
||||
if(!isNearGround() &&
|
||||
MaxSpeed::getSpeedIncreaseTimeLeft(MS_INCREASE_ZIPPER)<=0.0f )
|
||||
m_uprightConstraint->setLimit(M_PI);
|
||||
else
|
||||
m_uprightConstraint->setLimit(m_kart_properties->getUprightTolerance());
|
||||
if (!m_flying)
|
||||
{
|
||||
// When really on air, free fly, when near ground, try to glide / adjust for landing
|
||||
// If zipped, be stable, so ramp+zipper can allow nice jumps without scripting the fly
|
||||
if(!isNearGround() &&
|
||||
MaxSpeed::getSpeedIncreaseTimeLeft(MS_INCREASE_ZIPPER)<=0.0f )
|
||||
m_uprightConstraint->setLimit(M_PI);
|
||||
else
|
||||
m_uprightConstraint->setLimit(m_kart_properties->getUprightTolerance());
|
||||
}
|
||||
|
||||
// TODO: hiker said this probably will be moved to btKart or so when updating bullet engine.
|
||||
// Neutralize any yaw change if the kart leaves the ground, so the kart falls more or less
|
||||
@ -1162,8 +1173,28 @@ void Kart::updatePhysics(float dt)
|
||||
+ handleSlipstream(dt);
|
||||
if(m_attachment->getType()==ATTACH_PARACHUTE) engine_power*=0.2f;
|
||||
|
||||
if (m_flying)
|
||||
{
|
||||
if (m_controls.m_accel)
|
||||
{
|
||||
float orientation = getHeading();
|
||||
m_body->applyCentralImpulse(btVector3(60.0f*sin(orientation), 0.0, 60.0f*cos(orientation)));
|
||||
}
|
||||
if (m_controls.m_steer != 0.0f)
|
||||
{
|
||||
m_body->applyTorque(btVector3(0.0, m_controls.m_steer * 2000.0f, 0.0));
|
||||
}
|
||||
if (m_controls.m_brake)
|
||||
{
|
||||
float orientation = getHeading();
|
||||
m_body->applyCentralImpulse(btVector3(-60.0f*sin(orientation), 0.0, -60.0f*cos(orientation)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(m_controls.m_accel) // accelerating
|
||||
{ // For a short time after a collision disable the engine,
|
||||
{
|
||||
// For a short time after a collision disable the engine,
|
||||
// so that the karts can bounce back a bit from the obstacle.
|
||||
if(m_bounce_back_time>0.0f)
|
||||
engine_power = 0.0f;
|
||||
|
@ -64,6 +64,9 @@ class Kart : public TerrainInfo, public Moveable, public EmergencyAnimation,
|
||||
public MaxSpeed
|
||||
{
|
||||
private:
|
||||
|
||||
bool m_flying;
|
||||
|
||||
/** Reset position. */
|
||||
btTransform m_reset_transform;
|
||||
/** Index of kart in world. */
|
||||
@ -226,6 +229,8 @@ public:
|
||||
float getActualWheelForce();
|
||||
bool isSlipstreamReady() const;
|
||||
|
||||
virtual void fly();
|
||||
|
||||
void resetBrakes ();
|
||||
void startEngineSFX ();
|
||||
void adjustSpeed (float f);
|
||||
|
@ -90,6 +90,26 @@ void Moveable::reset()
|
||||
|
||||
} // reset
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void Moveable::fly()
|
||||
{
|
||||
m_body->setGravity(btVector3(0.0, 8.0, 0.0));
|
||||
//m_body->setMassProps( 0.0, btVector3(0.0, 0.0, 0.0) );
|
||||
flyUp();
|
||||
//m_body->applyCentralForce( btVector3(0.0, 9000.0, 0.0) );
|
||||
}
|
||||
|
||||
void Moveable::flyUp()
|
||||
{
|
||||
m_body->applyCentralImpulse(btVector3(0.0, 100.0, 0.0));
|
||||
}
|
||||
|
||||
void Moveable::flyDown()
|
||||
{
|
||||
m_body->applyCentralImpulse(btVector3(0.0, -100.0, 0.0));
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Updates the current position and rotation from the corresponding physics
|
||||
* body, and then calls updateGraphics to position the model correctly.
|
||||
|
@ -85,6 +85,11 @@ public:
|
||||
const btQuaternion
|
||||
getRotation() const {return m_transform.getRotation(); }
|
||||
|
||||
/** Enter flying mode */
|
||||
virtual void fly();
|
||||
virtual void flyUp();
|
||||
virtual void flyDown();
|
||||
|
||||
/** Sets the XYZ coordinates of the moveable. */
|
||||
void setXYZ(const Vec3& a)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user