Added a little jump (duration set in config file) when
starting to skid. git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@10965 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
4e02fe9d6c
commit
330c269f42
@ -185,8 +185,8 @@
|
|||||||
visual="1.0" visual-time="0"
|
visual="1.0" visual-time="0"
|
||||||
time-till-bonus="1.0 3.0"
|
time-till-bonus="1.0 3.0"
|
||||||
bonus-speed="4.5 6.5" bonus-time="3.0 4.0"
|
bonus-speed="4.5 6.5" bonus-time="3.0 4.0"
|
||||||
post-skid-rotate-factor="1" reduce-turn-min="0.3"
|
post-skid-rotate-factor="1" jump-time="0.4"
|
||||||
reduce-turn-max="0.8"/>
|
reduce-turn-min="0.4" reduce-turn-max="0.8"/>
|
||||||
|
|
||||||
<!-- Slipstream: length: How far behind a kart slipstream works
|
<!-- Slipstream: length: How far behind a kart slipstream works
|
||||||
collect-time: How many seconds of sstream give maximum benefit
|
collect-time: How many seconds of sstream give maximum benefit
|
||||||
|
@ -21,7 +21,9 @@
|
|||||||
#include "karts/kart.hpp"
|
#include "karts/kart.hpp"
|
||||||
#include "karts/kart_gfx.hpp"
|
#include "karts/kart_gfx.hpp"
|
||||||
#include "karts/kart_properties.hpp"
|
#include "karts/kart_properties.hpp"
|
||||||
|
#include "modes/world.hpp"
|
||||||
#include "physics/btKart.hpp"
|
#include "physics/btKart.hpp"
|
||||||
|
#include "tracks/track.hpp"
|
||||||
|
|
||||||
/** Constructor of the skidding object.
|
/** Constructor of the skidding object.
|
||||||
*/
|
*/
|
||||||
@ -155,17 +157,29 @@ void Skidding::update(float dt, bool is_on_ground,
|
|||||||
switch(m_skid_state)
|
switch(m_skid_state)
|
||||||
{
|
{
|
||||||
case SKID_NONE:
|
case SKID_NONE:
|
||||||
// If skidding is pressed while the kart is going straight,
|
{
|
||||||
// do nothing (till the kart starts to steer in one direction).
|
// If skidding is pressed while the kart is going straight,
|
||||||
// Just testing for the sign of steering can result in unexpected
|
// do nothing (till the kart starts to steer in one direction).
|
||||||
// beahviour, e.g. if a player is still turning left, but already
|
// Just testing for the sign of steering can result in unexpected
|
||||||
// presses right (it will take a few frames for this steering to
|
// beahviour, e.g. if a player is still turning left, but already
|
||||||
// actuallu take place, see player_controller) - the kart would skid
|
// presses right (it will take a few frames for this steering to
|
||||||
// to the left. So we test for a 'clear enough' steering direction.
|
// actuallu take place, see player_controller) - the kart would skid
|
||||||
if(!skidding || fabsf(steering)<0.3f) break;
|
// to the left. So we test for a 'clear enough' steering direction.
|
||||||
m_skid_state = steering > 0 ? SKID_ACCUMULATE_RIGHT
|
if(!skidding || fabsf(steering)<0.3f) break;
|
||||||
: SKID_ACCUMULATE_LEFT;
|
m_skid_state = steering > 0 ? SKID_ACCUMULATE_RIGHT
|
||||||
m_skid_time = 0; // fallthrough
|
: SKID_ACCUMULATE_LEFT;
|
||||||
|
m_skid_time = 0; // fallthrough
|
||||||
|
|
||||||
|
// Add a little jump to the kart. Determine the vertical speed
|
||||||
|
// necessary for the kart to go 0.5*jump_time up (then it needs
|
||||||
|
// the same time to come down again), based on v = gravity * t.
|
||||||
|
// Then use this speed to determine the impulse necessary to
|
||||||
|
// reach this speed.
|
||||||
|
float v = World::getWorld()->getTrack()->getGravity()
|
||||||
|
* 0.5f*m_jump_time;
|
||||||
|
btVector3 imp(0, v / m_kart->getBody()->getInvMass(),0);
|
||||||
|
m_kart->getVehicle()->getRigidBody()->applyCentralImpulse(imp);
|
||||||
|
}
|
||||||
case SKID_ACCUMULATE_LEFT:
|
case SKID_ACCUMULATE_LEFT:
|
||||||
case SKID_ACCUMULATE_RIGHT:
|
case SKID_ACCUMULATE_RIGHT:
|
||||||
{
|
{
|
||||||
|
@ -35,6 +35,7 @@ SkiddingProperties::SkiddingProperties()
|
|||||||
m_post_skid_rotate_factor = UNDEFINED;
|
m_post_skid_rotate_factor = UNDEFINED;
|
||||||
m_skid_reduce_turn_min = UNDEFINED;
|
m_skid_reduce_turn_min = UNDEFINED;
|
||||||
m_skid_reduce_turn_max = UNDEFINED;
|
m_skid_reduce_turn_max = UNDEFINED;
|
||||||
|
m_jump_time = UNDEFINED;
|
||||||
m_has_skidmarks = true;
|
m_has_skidmarks = true;
|
||||||
|
|
||||||
m_skid_bonus_time.clear();
|
m_skid_bonus_time.clear();
|
||||||
@ -58,6 +59,7 @@ void SkiddingProperties::load(const XMLNode *skid_node)
|
|||||||
skid_node->get("bonus-time", &m_skid_bonus_time );
|
skid_node->get("bonus-time", &m_skid_bonus_time );
|
||||||
skid_node->get("bonus-speed", &m_skid_bonus_speed );
|
skid_node->get("bonus-speed", &m_skid_bonus_speed );
|
||||||
skid_node->get("time-till-bonus", &m_skid_time_till_bonus );
|
skid_node->get("time-till-bonus", &m_skid_time_till_bonus );
|
||||||
|
skid_node->get("jump-time", &m_jump_time );
|
||||||
} // load
|
} // load
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@ -67,15 +69,16 @@ void SkiddingProperties::checkAllSet(const std::string &filename) const
|
|||||||
fprintf(stderr,"Missing default value for '%s' in '%s'.\n", \
|
fprintf(stderr,"Missing default value for '%s' in '%s'.\n", \
|
||||||
strA,filename.c_str());exit(-1); \
|
strA,filename.c_str());exit(-1); \
|
||||||
}
|
}
|
||||||
CHECK_NEG(m_skid_increase, "skid increase" );
|
CHECK_NEG(m_skid_increase, "skid increase" );
|
||||||
CHECK_NEG(m_skid_decrease, "skid decrease" );
|
CHECK_NEG(m_skid_decrease, "skid decrease" );
|
||||||
CHECK_NEG(m_skid_max, "skid max" );
|
CHECK_NEG(m_skid_max, "skid max" );
|
||||||
CHECK_NEG(m_time_till_max_skid, "skid time-till-max" );
|
CHECK_NEG(m_time_till_max_skid, "skid time-till-max" );
|
||||||
CHECK_NEG(m_skid_visual, "skid visual" );
|
CHECK_NEG(m_skid_visual, "skid visual" );
|
||||||
CHECK_NEG(m_skid_visual_time, "skid visual-time" );
|
CHECK_NEG(m_skid_visual_time, "skid visual-time" );
|
||||||
CHECK_NEG(m_post_skid_rotate_factor, "skid post-skid-rotate-factor" );
|
CHECK_NEG(m_post_skid_rotate_factor, "skid post-skid-rotate-factor" );
|
||||||
CHECK_NEG(m_skid_reduce_turn_min, "skid reduce-turn-min" );
|
CHECK_NEG(m_skid_reduce_turn_min, "skid reduce-turn-min" );
|
||||||
CHECK_NEG(m_skid_reduce_turn_max, "skid reduce-turn-max" );
|
CHECK_NEG(m_skid_reduce_turn_max, "skid reduce-turn-max" );
|
||||||
|
CHECK_NEG(m_jump_time, "skid jump-time" );
|
||||||
|
|
||||||
if(m_skid_time_till_bonus.size()==0)
|
if(m_skid_time_till_bonus.size()==0)
|
||||||
fprintf(stderr, "Warning: no skid time declared, can be ignored.\n");
|
fprintf(stderr, "Warning: no skid time declared, can be ignored.\n");
|
||||||
@ -105,7 +108,6 @@ void SkiddingProperties::checkAllSet(const std::string &filename) const
|
|||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
void SkiddingProperties::copyFrom(const SkiddingProperties *destination)
|
void SkiddingProperties::copyFrom(const SkiddingProperties *destination)
|
||||||
{
|
{
|
||||||
//memcpy(this, destination, sizeof(SkiddingProperties));
|
|
||||||
*this = *destination;
|
*this = *destination;
|
||||||
} // copyFrom
|
} // copyFrom
|
||||||
|
|
||||||
|
@ -59,6 +59,9 @@ protected:
|
|||||||
/** Additional rotation of 3d model when skidding. */
|
/** Additional rotation of 3d model when skidding. */
|
||||||
float m_skid_visual;
|
float m_skid_visual;
|
||||||
|
|
||||||
|
/** Time for a small jump when skidding starts. */
|
||||||
|
float m_jump_time;
|
||||||
|
|
||||||
/** This factor is used to determine how much the chassis of a kart
|
/** This factor is used to determine how much the chassis of a kart
|
||||||
* should rotate to match the graphical view. A factor of 1 is
|
* should rotate to match the graphical view. A factor of 1 is
|
||||||
* identical, a smaller factor will rotate the kart less (which might
|
* identical, a smaller factor will rotate the kart less (which might
|
||||||
|
Loading…
x
Reference in New Issue
Block a user