Added indication when the skid bonus 1 and 2 is reached. ATM this

still looks like nitro, and there the bonus of bonus 1 and 2
is actually still the same (wip).


git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@10754 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
hikerstk 2012-01-29 22:31:40 +00:00
parent b68e849521
commit 35d02e2547
8 changed files with 129 additions and 21 deletions

32
data/gfx/skid1.xml Normal file
View File

@ -0,0 +1,32 @@
<?xml version="1.0"?>
<particles emitter="box" box_x="0.35" box_y="0.2" box_z="0.2">
<spreading angle="30" />
<velocity x="0.0"
y="0.001"
z="-0.003" />
<material file="nitro-particle.png" />
<!-- Amount of particles emitted per second. The minimum rate
is used to show that the skidding bonus is now available,
the maximum is used when the skid bonus is applied to the kart -->
<rate min="50"
max="600" />
<!-- Minimal and maximal lifetime of a particle, in milliseconds. -->
<lifetime min="400"
max="600" />
<!-- Size of the particles -->
<size min="0.20"
max="0.40" />
<color min="255 255 255"
max="255 255 255" />
<!-- How much time in milliseconds before the particle is fully faded out -->
<fadeout time="100" />
</particles>

32
data/gfx/skid2.xml Normal file
View File

@ -0,0 +1,32 @@
<?xml version="1.0"?>
<particles emitter="box" box_x="0.35" box_y="0.2" box_z="0.2">
<spreading angle="30" />
<velocity x="0.0"
y="0.001"
z="-0.003" />
<material file="nitro-particle.png" />
<!-- Amount of particles emitted per second. The minimum rate
is used to show that the skidding bonus is now available,
the maximum is used when the skid bonus is applied to the kart -->
<rate min="200"
max="600" />
<!-- Minimal and maximal lifetime of a particle, in milliseconds. -->
<lifetime min="400"
max="600" />
<!-- Size of the particles -->
<size min="0.20"
max="0.40" />
<color min="255 255 255"
max="255 255 255" />
<!-- How much time in milliseconds before the particle is fully faded out -->
<fadeout time="100" />
</particles>

View File

@ -172,11 +172,11 @@
less (which might feel better).
reduce-turn: A factor that's multiplied to the steering when skidding,
which is used to reduce the turn angle used to reduce the turn angle. -->
<skid increase="1.05" decrease="0.95" max="2.5" time-till-max="0.4"
visual="1.9" visual-time="0"
angular-velocity="0" time-till-bonus="1.5 2"
bonus-force="100 200" bonus-time="3.0 3.0"
post-skid-rotate-factor="0.33" reduce-turn="0.6"/>
<skid increase="1.05" decrease="0.95" max="2.5" time-till-max="0.5"
visual="1.0" visual-time="0"
angular-velocity="0" time-till-bonus="1.5 2.5"
bonus-force="100 200" bonus-time="3.0 4.0"
post-skid-rotate-factor="1" reduce-turn="0.6"/>
<!-- Slipstream: length: How far behind a kart slipstream works
collect-time: How many seconds of sstream give maximum benefit

View File

@ -1765,6 +1765,17 @@ void Kart::updateSkidding(float dt)
ang_vel = m_kart_properties->getSkidAngularVelocity();
else if (m_controls.m_steer<0)
ang_vel = -m_kart_properties->getSkidAngularVelocity();
float bonus_time, bonus_force;
unsigned int level = m_kart_properties->getSkidBonus(m_skid_time,
&bonus_time,
&bonus_force);
// Relative 0 means it will emitt the minimum rate, i.e. the rate
// set to indicate that the bonus is now available.
if(level>0)
{
m_kart_gfx->setSkidLevel(level);
m_kart_gfx->setCreationRateRelative(KartGFX::KGFX_SKID, 0.0f);
}
}
else if(m_skid_time>0 &&
// FIXME hiker: remove once the new skidding code is finished.
@ -1772,8 +1783,8 @@ void Kart::updateSkidding(float dt)
{
// The kart just stopped skidding - see if a skid bonus applies
float bonus_time, bonus_force;
m_kart_properties->getSkidBonus(m_skid_time,
&bonus_time, &bonus_force);
int level = m_kart_properties->getSkidBonus(m_skid_time,
&bonus_time, &bonus_force);
float t = (m_skid_time <= m_kart_properties->getSkidVisualTime())
? m_skid_time
: m_kart_properties->getSkidVisualTime();
@ -1787,15 +1798,21 @@ void Kart::updateSkidding(float dt)
{
MaxSpeed::increaseMaxSpeed(MaxSpeed::MS_INCREASE_SKIDDING,
10, bonus_time, 1);
m_kart_gfx->setCreationRateRelative(KartGFX::KGFX_SKID, 1.0f);
// FIXME hiker: for now just misuse the zipper code
handleZipper(0);
}
else
m_kart_gfx->setCreationRateAbsolute(KartGFX::KGFX_SKID, 0);
}
else if (m_skid_time < 0)
{
m_skid_time += dt;
if(m_skid_time>0)
{
m_skid_time = 0;
m_kart_gfx->setCreationRateAbsolute(KartGFX::KGFX_SKID, 0);
}
}
m_vehicle->setSkidAngularVelocity(ang_vel);
} // updateSkidding

View File

@ -26,7 +26,7 @@
#include <iostream>
KartGFX::KartGFX(const Kart *kart)
KartGFX::KartGFX(const Kart *kart) : m_current_skid(KGFX_SKID1)
{
if(!UserConfigParams::m_graphical_effects)
{
@ -47,7 +47,8 @@ KartGFX::KartGFX(const Kart *kart)
// in the order of KartGFXType.
addEffect(KGFX_NITRO, "nitro.xml", position);
addEffect(KGFX_ZIPPER, "zipper_fire.xml", position);
addEffect(KGFX_SKID, "nitro.xml", position);
addEffect(KGFX_SKID1, "skid1.xml", position);
addEffect(KGFX_SKID2, "skid2.xml", position);
} // KartGFX
@ -79,9 +80,12 @@ void KartGFX::addEffect(KartGFXType type, const std::string &file_name,
try
{
kind = new ParticleKind(file_manager->getGfxFile(file_name));
emitter = new ParticleEmitter(kind,
position,
m_kart->getNode() );
if(type==KGFX_SKID2)
emitter = NULL; // skid2 is only used to store the emitter type
else
emitter = new ParticleEmitter(kind,
position,
m_kart->getNode());
}
catch (std::runtime_error& e)
{
@ -112,6 +116,21 @@ void KartGFX::reset()
}
} // reset
// ----------------------------------------------------------------------------
/** Selects the correct skidding particle type depending on skid bonus level.
* \param type Must be either KGFX_SKID1 or KGFX_SKID2 - the particle type
* to use corresponding to the bonus level.
*/
void KartGFX::setSkidLevel(unsigned int level)
{
KartGFXType type = level==1 ? KGFX_SKID1 : KGFX_SKID2;
assert(type == KGFX_SKID1 || type==KGFX_SKID2);
m_current_skid = type;
if(m_all_emitters[KGFX_SKID1])
m_all_emitters[KGFX_SKID1]->setParticleType(
m_all_particle_kinds[type]);
} // setSkidLevel
// ----------------------------------------------------------------------------
/** Updates all gfx.
* \param dt Time step size.

View File

@ -39,10 +39,12 @@ public:
enum KartGFXType { KGFX_NITRO=0,
KGFX_ZIPPER,
KGFX_SKID,
KGFX_SKID1=KGFX_SKID,
KGFX_SKID2,
KGFX_COUNT};
private:
/** Vector of all particle kinds. */
/** Vector of all particle kinde. */
std::vector<ParticleKind*> m_all_particle_kinds;
/** Vector of all particle emitters. */
@ -51,6 +53,9 @@ private:
/** Pointer to the owner of this kart. */
const Kart *m_kart;
/** Indicates the current skidding level, either skid1 or skid2. */
KartGFXType m_current_skid;
void addEffect(KartGFXType type, const std::string &file_name,
const Vec3 &position);
@ -62,5 +67,6 @@ public:
void setCreationRateAbsolute(KartGFXType type, float f);
void setCreationRateRelative(KartGFXType type, float f);
void resizeBox(KartGFXType type, float speed, float dt);
void setSkidLevel(unsigned int level);
}; // KartWGFX
#endif

View File

@ -718,22 +718,23 @@ float KartProperties::getMaxSteerAngle(float speed) const
} // getMaxSteerAngle
// ----------------------------------------------------------------------------
/** Returns the bonus force to be applied to a kart which has skidded for the
* specified amount of time.
/** Determines the bonus force to be applied to a kart which has skidded for
* the specified amount of time. It returns which level of skid bonus to use.
* \param t Time the kart has skidded.
* \return The 'level' of skid bonus: 0=no bonus, 1=level 1, 2=level 2 etc.
*/
void KartProperties::getSkidBonus(float t, float *bonus_time,
float *bonus_force) const
unsigned int KartProperties::getSkidBonus(float t, float *bonus_time,
float *bonus_force) const
{
*bonus_time = 0;
*bonus_force = 0;
for(unsigned int i=0; i<m_skid_bonus_force.size(); i++)
{
if(t<=m_skid_time_till_bonus[i]) return ;
if(t<=m_skid_time_till_bonus[i]) return i;
*bonus_force = m_skid_bonus_force[i];
*bonus_time= m_skid_bonus_time[i];
}
return;
return m_skid_bonus_force.size();
} // getSkidBonusForce
// ----------------------------------------------------------------------------

View File

@ -293,7 +293,7 @@ private:
float m_skid_increase;
/** Skidding is multiplied by this when not skidding to decrease to 1.0. */
float m_skid_decrease;
/**< Time till maximum skidding is reached. */
/** Time till maximum skidding is reached. */
float m_time_till_max_skid;
/** Additional rotation of 3d model when skidding. */
float m_skid_visual;
@ -371,7 +371,8 @@ public:
/** Returns the maximum steering angle (depending on speed). */
float getMaxSteerAngle (float speed) const;
void getSkidBonus(float t, float *bonus_time, float *bonus_force) const;
unsigned int getSkidBonus(float t, float *bonus_time,
float *bonus_force) const;
/** Returns the material for the kart icons. */
Material* getIconMaterial () const {return m_icon_material; }