From 77914fcf05c1877e5be1ba8d7003b36cad0159f6 Mon Sep 17 00:00:00 2001 From: hikerstk Date: Fri, 26 Dec 2008 20:05:41 +0000 Subject: [PATCH] Made the skidding frame rate independent. git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@2784 178a84e3-b1eb-0310-8ba1-8eac791a3b58 --- data/stk_config.data | 1 + src/karts/kart.cpp | 6 ++++-- src/karts/kart_properties.cpp | 4 +++- src/karts/kart_properties.hpp | 5 +++++ 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/data/stk_config.data b/data/stk_config.data index a14594a91..732fadc57 100644 --- a/data/stk_config.data +++ b/data/stk_config.data @@ -74,6 +74,7 @@ ;; in each frame. (skid-max 2.5 ) ;; Maximum skidding factor = maximum increase ;; of steering angle. + (time-till-max-skid 0.4 ) ;; Time till maximum skidding is reached. (skid-visual 0.16) ;; Additional graphical rotation of kart. ;; Bullet physics attributes diff --git a/src/karts/kart.cpp b/src/karts/kart.cpp index 09cf50555..00d44d98e 100644 --- a/src/karts/kart.cpp +++ b/src/karts/kart.cpp @@ -721,7 +721,8 @@ void Kart::updatePhysics (float dt) //apply the brakes for(int i=0; i<4; i++) m_vehicle->setBrake(getBrakeFactor() * 4.0f, i); m_skidding*= 1.08f;//skid a little when the brakes are hit (just enough to make the skiding sound) - if(m_skidding>2.0f) m_skidding=2.0f; + if(m_skidding>m_kart_properties->getMaxSkid()) + m_skidding=m_kart_properties->getMaxSkid(); } else { @@ -769,7 +770,8 @@ void Kart::updatePhysics (float dt) #endif if(m_controls.m_drift) { - m_skidding*= m_kart_properties->getSkidIncrease(); + m_skidding += m_kart_properties->getSkidIncrease() + *dt/m_kart_properties->getTimeTillMaxSkid(); if(m_skidding>m_kart_properties->getMaxSkid()) m_skidding=m_kart_properties->getMaxSkid(); } diff --git a/src/karts/kart_properties.cpp b/src/karts/kart_properties.cpp index c384e86f3..7cc5b0f39 100644 --- a/src/karts/kart_properties.cpp +++ b/src/karts/kart_properties.cpp @@ -69,7 +69,7 @@ KartProperties::KartProperties() : m_icon_material(0) m_track_connection_accel = m_min_speed_turn = m_angle_at_min = m_max_speed_turn = m_angle_at_max = m_rubber_band_max_length = m_rubber_band_force = - m_rubber_band_duration = + m_rubber_band_duration = m_time_till_max_skid = m_skid_decrease = m_skid_increase = m_skid_visual = m_skid_max = m_camera_max_accel = m_camera_max_brake = m_camera_distance = UNDEFINED; @@ -253,6 +253,7 @@ void KartProperties::getAllData(const lisp::Lisp* lisp) lisp->get("skid-increase", m_skid_increase ); lisp->get("skid-decrease", m_skid_decrease ); + lisp->get("time-till-max-skid", m_time_till_max_skid ); lisp->get("skid-max", m_skid_max ); lisp->get("skid-visual", m_skid_visual ); @@ -339,6 +340,7 @@ void KartProperties::checkAllSet(const std::string &filename) CHECK_NEG(m_rubber_band_force, "rubber-band-force" ); CHECK_NEG(m_rubber_band_duration, "rubber-band-duration" ); CHECK_NEG(m_skid_decrease, "skid-decrease" ); + CHECK_NEG(m_time_till_max_skid, "time-till-max-skid" ); CHECK_NEG(m_skid_increase, "skid-increase" ); CHECK_NEG(m_skid_max, "skid-max" ); CHECK_NEG(m_skid_visual, "skid-visual" ); diff --git a/src/karts/kart_properties.hpp b/src/karts/kart_properties.hpp index d69bc1bdd..327acfb8c 100644 --- a/src/karts/kart_properties.hpp +++ b/src/karts/kart_properties.hpp @@ -136,6 +136,8 @@ protected: * m_skid_increase. */ float m_skid_decrease; /**< Skidding is multiplied by this when * not skidding to decrease to 1.0. */ + float m_time_till_max_skid; /**< Time till maximum skidding is + * reached. */ // Camera related setting // ---------------------- float m_camera_max_accel; // maximum acceleration of camera @@ -218,6 +220,9 @@ public: /** Returns the factor by which m_skidding is multiplied when the kart is * not skidding to decrease it back to 1.0f . */ float getSkidDecrease () const {return m_skid_decrease; } + /** Returns the time (in seconds) of drifting till the maximum skidding + * is reached. */ + float getTimeTillMaxSkid () const {return m_time_till_max_skid; } const std::vector& getGearSwitchRatio () const {return m_gear_switch_ratio; } const std::vector&