Make the visual kart scale

This commit is contained in:
Alayan 2018-09-21 05:56:38 +02:00
parent 6a9a1a0e7a
commit d9581d9f70
3 changed files with 10 additions and 7 deletions

View File

@ -286,7 +286,7 @@ public:
virtual void unsetSuper(bool instant) = 0; virtual void unsetSuper(bool instant) = 0;
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
/** Updates the kart's current scaling */ /** Updates the kart's current scaling */
virtual void updateScale() = 0; virtual void updateScale(int ticks) = 0;
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
/** Returns the speed of the kart in meters/second. This is not declared /** Returns the speed of the kart in meters/second. This is not declared
* pure abstract, since this function is not needed for certain classes, * pure abstract, since this function is not needed for certain classes,

View File

@ -1876,7 +1876,7 @@ void Kart::setSuper()
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
/** Update the scale according to m_scale_change_ticks /** Update the scale according to m_scale_change_ticks
*/ */
void Kart::updateScale() void Kart::updateScale(int ticks)
{ {
//TODO update physics model too //TODO update physics model too
if (m_scale_change_ticks == 0) return; if (m_scale_change_ticks == 0) return;
@ -1884,12 +1884,14 @@ void Kart::updateScale()
float scale_factor; float scale_factor;
if (m_scale_change_ticks > 0) if (m_scale_change_ticks > 0)
{ {
m_scale_change_ticks--; m_scale_change_ticks -= ticks;
if (m_scale_change_ticks < 0) m_scale_change_ticks = 0;
scale_factor = 1.4 - (m_scale_change_ticks*0.01); scale_factor = 1.4 - (m_scale_change_ticks*0.01);
} }
else else
{ {
m_scale_change_ticks++; m_scale_change_ticks += ticks;
if (m_scale_change_ticks > 0) m_scale_change_ticks = 0;
scale_factor = 1.0 - (m_scale_change_ticks*0.01); scale_factor = 1.0 - (m_scale_change_ticks*0.01);
} }
@ -1910,7 +1912,6 @@ void Kart::unsetSuper(bool instant)
// This resets the speed boost // This resets the speed boost
m_max_speed->increaseMaxSpeed(MaxSpeed::MS_INCREASE_SUPER, m_max_speed->increaseMaxSpeed(MaxSpeed::MS_INCREASE_SUPER,
0, 0, 0, 0); 0, 0, 0, 0);
//TODO : force end the max speed bonus
} }
else else
{ {
@ -2583,7 +2584,7 @@ void Kart::updatePhysics(int ticks)
{ {
if (m_super_time != std::numeric_limits<float>::max()) if (m_super_time != std::numeric_limits<float>::max())
{ {
m_squash_time -= stk_config->ticks2Time(ticks); m_super_time -= stk_config->ticks2Time(ticks);
// If super time ends, reset the model // If super time ends, reset the model
if (m_super_time <= 0.0f) if (m_super_time <= 0.0f)
{ {
@ -2591,6 +2592,8 @@ void Kart::updatePhysics(int ticks)
} }
} // if super } // if super
updateScale(ticks);
if (m_controls.getAccel() > 0.0f && if (m_controls.getAccel() > 0.0f &&
World::getWorld()->getTicksSinceStart() == 1) World::getWorld()->getTicksSinceStart() == 1)
{ {

View File

@ -322,7 +322,7 @@ public:
virtual void setSuper () OVERRIDE; virtual void setSuper () OVERRIDE;
virtual void unsetSuper (bool instant) OVERRIDE; virtual void unsetSuper (bool instant) OVERRIDE;
virtual void updateScale () OVERRIDE; virtual void updateScale (int ticks) OVERRIDE;
virtual void crashed (AbstractKart *k, bool update_attachments) OVERRIDE; virtual void crashed (AbstractKart *k, bool update_attachments) OVERRIDE;
virtual void crashed (const Material *m, const Vec3 &normal) OVERRIDE; virtual void crashed (const Material *m, const Vec3 &normal) OVERRIDE;