From 893a0c269272109ab480746033785b586754c0b8 Mon Sep 17 00:00:00 2001 From: hiker Date: Fri, 15 Jun 2007 02:06:26 +0000 Subject: [PATCH] Fixed braking behaviour when driving backwards: in this case, accelerating should be braking (and work with more force than just accelerating). git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@1155 178a84e3-b1eb-0310-8ba1-8eac791a3b58 --- src/kart.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/kart.cpp b/src/kart.cpp index e7f611568..18cdff981 100644 --- a/src/kart.cpp +++ b/src/kart.cpp @@ -864,8 +864,16 @@ void Kart::updatePhysics (float dt) } else { // not braking - m_vehicle->applyEngineForce(m_controls.accel*engine_power, 2); - m_vehicle->applyEngineForce(m_controls.accel*engine_power, 3); + if(m_speed < 0.0f) // if going backwards, accelerating is braking + { + m_vehicle->setBrake(getBrakeForce(), 2); + m_vehicle->setBrake(getBrakeForce(), 3); + } + else + { + m_vehicle->applyEngineForce(m_controls.accel*engine_power, 2); + m_vehicle->applyEngineForce(m_controls.accel*engine_power, 3); + } } if(m_controls.jump) @@ -934,11 +942,12 @@ void Kart::updatePhysics (float dt) { if(m_controls.brake) { - throttle = m_velocity.xyz[1]<0.0 ? -1.0f : -getBrakeFactor(); + throttle = m_velocity.xyz[1]<0.0f ? -1.0f : -getBrakeFactor(); } else { // not braking - throttle = m_controls.accel*m_current_friction*m_current_friction; + throttle = m_velocity.xyz[1]<0.0f ? getBrakeFactor() + : m_controls.accel*m_current_friction*m_current_friction; } // Handle wheelies // ===============