At everyone's request, including Grand Master Joerg, improved fly hack ;) The controls are now simplified : no more J key, just I for up up and K for down. Also, it is now possible to land back on ground : simply go down until to hit the track. Also, the track also gains gravity back when rescued. Finally, the back key is now a break instead of moving backwards, this should be more useful during testing
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@6474 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
@@ -95,12 +95,6 @@ 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);
|
||||
|
||||
@@ -268,11 +268,25 @@ void Kart::createPhysics()
|
||||
|
||||
} // createPhysics
|
||||
|
||||
void Kart::fly()
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void Kart::flyUp()
|
||||
{
|
||||
m_flying = true;
|
||||
Moveable::fly();
|
||||
//m_vehicle->m_flying = true;
|
||||
Moveable::flyUp();
|
||||
}
|
||||
|
||||
void Kart::flyDown()
|
||||
{
|
||||
if (isNearGround())
|
||||
{
|
||||
stopFlying();
|
||||
m_flying = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
Moveable::flyDown();
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -387,6 +401,12 @@ void Kart::updatedWeight()
|
||||
*/
|
||||
void Kart::reset()
|
||||
{
|
||||
if (m_flying)
|
||||
{
|
||||
m_flying = false;
|
||||
stopFlying();
|
||||
}
|
||||
|
||||
EmergencyAnimation::reset();
|
||||
MaxSpeed::reset();
|
||||
if (m_camera)
|
||||
@@ -680,6 +700,7 @@ void Kart::update(float dt)
|
||||
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
|
||||
@@ -1190,12 +1211,31 @@ void Kart::updatePhysics(float dt)
|
||||
}
|
||||
if (m_controls.m_steer != 0.0f)
|
||||
{
|
||||
m_body->applyTorque(btVector3(0.0, m_controls.m_steer * 2000.0f, 0.0));
|
||||
m_body->applyTorque(btVector3(0.0, m_controls.m_steer * 3500.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)));
|
||||
btVector3 velocity = m_body->getLinearVelocity();
|
||||
|
||||
const int x = velocity.x();
|
||||
if (x > 0.2) velocity.setX(x - 0.2);
|
||||
else if (x < -0.2) velocity.setX(x + 0.2);
|
||||
else velocity.setX(0);
|
||||
|
||||
const int y = velocity.y();
|
||||
if (y > 0.2) velocity.setY(y - 0.2);
|
||||
else if (y < -0.2) velocity.setY(y + 0.2);
|
||||
else velocity.setY(0);
|
||||
|
||||
const int z = velocity.z();
|
||||
if (z > 0.2) velocity.setZ(z - 0.2);
|
||||
else if (z < -0.2) velocity.setZ(z + 0.2);
|
||||
else velocity.setZ(0);
|
||||
|
||||
m_body->setLinearVelocity(velocity);
|
||||
|
||||
//float orientation = getHeading();
|
||||
//m_body->applyCentralImpulse(btVector3(-60.0f*sin(orientation), 0.0, -60.0f*cos(orientation)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -225,7 +225,8 @@ public:
|
||||
float getActualWheelForce();
|
||||
bool isSlipstreamReady() const;
|
||||
|
||||
virtual void fly();
|
||||
virtual void flyUp();
|
||||
virtual void flyDown();
|
||||
|
||||
void resetBrakes ();
|
||||
void startEngineSFX ();
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
#include "graphics/irr_driver.hpp"
|
||||
#include "graphics/material.hpp"
|
||||
#include "graphics/material_manager.hpp"
|
||||
#include "modes/world.hpp"
|
||||
#include "tracks/track.hpp"
|
||||
|
||||
Moveable::Moveable()
|
||||
{
|
||||
@@ -92,16 +94,9 @@ void Moveable::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->setGravity(btVector3(0.0, 8.0, 0.0));
|
||||
m_body->applyCentralImpulse(btVector3(0.0, 100.0, 0.0));
|
||||
}
|
||||
|
||||
@@ -110,6 +105,11 @@ void Moveable::flyDown()
|
||||
m_body->applyCentralImpulse(btVector3(0.0, -100.0, 0.0));
|
||||
}
|
||||
|
||||
void Moveable::stopFlying()
|
||||
{
|
||||
m_body->setGravity(btVector3(0.0, -World::getWorld()->getTrack()->getGravity(), 0.0));
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Updates the current position and rotation from the corresponding physics
|
||||
* body, and then calls updateGraphics to position the model correctly.
|
||||
|
||||
@@ -86,9 +86,9 @@ public:
|
||||
getRotation() const {return m_transform.getRotation(); }
|
||||
|
||||
/** Enter flying mode */
|
||||
virtual void fly();
|
||||
virtual void flyUp();
|
||||
virtual void flyDown();
|
||||
virtual void stopFlying();
|
||||
|
||||
/** Sets the XYZ coordinates of the moveable. */
|
||||
void setXYZ(const Vec3& a)
|
||||
|
||||
Reference in New Issue
Block a user