Use a required minimal amount of nitro each time the key is used. May need some playtesting to balance but the base is there and shouldn't penalize normal use

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@13275 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria 2013-07-18 22:46:46 +00:00
parent 2ff62c4d97
commit bfad6cc851
2 changed files with 38 additions and 7 deletions

View File

@ -81,6 +81,8 @@
# include <math.h>
#endif
const float MIN_NITRO_TIME_THRESHOLD = 2.0f;
/** The kart constructor.
* \param ident The identifier for the kart model to use.
* \param position The position (or rank) for this kart (between 1 and
@ -121,6 +123,8 @@ Kart::Kart (const std::string& ident, unsigned int world_kart_id,
m_stars_effect = NULL;
m_jump_time = 0;
m_is_jumping = false;
m_min_nitro_time = 0.0f;
m_view_blocked_by_plunger = 0;
m_has_caught_nolok_bubblegum = false;
@ -293,6 +297,8 @@ void Kart::reset()
if(m_body)
World::getWorld()->getPhysics()->addKart(this);
m_min_nitro_time = 0.0f;
// Reset star effect in case that it is currently being shown.
m_stars_effect->reset();
m_max_speed->reset();
@ -1530,18 +1536,40 @@ void Kart::handleZipper(const Material *material, bool play_sound)
*/
void Kart::updateNitro(float dt)
{
if(!m_controls.m_nitro || !isOnGround()) return;
if (m_controls.m_nitro && m_min_nitro_time <= 0.0f)
{
m_min_nitro_time = MIN_NITRO_TIME_THRESHOLD;
}
if (m_min_nitro_time > 0.0f)
{
m_min_nitro_time -= dt;
// when pressing the key, don't allow the min time to go under zero.
// If it went under zero, it would be reset
if (m_controls.m_nitro && m_min_nitro_time <= 0.0f)
m_min_nitro_time = 0.1f;
}
bool increase_speed = (m_controls.m_nitro && isOnGround());
if (!increase_speed && m_min_nitro_time <= 0.0f)
{
return;
}
m_collected_energy -= dt * m_kart_properties->getNitroConsumption();
if(m_collected_energy<0)
if (m_collected_energy < 0)
{
m_collected_energy = 0;
return;
}
if (increase_speed)
{
m_max_speed->increaseMaxSpeed(MaxSpeed::MS_INCREASE_NITRO,
m_kart_properties->getNitroMaxSpeedIncrease(),
m_kart_properties->getNitroEngineForce(),
m_kart_properties->getNitroDuration(),
m_kart_properties->getNitroFadeOutTime() );
}
} // updateNitro
// -----------------------------------------------------------------------------

View File

@ -208,6 +208,9 @@ private:
SFXBase *m_goo_sound;
float m_time_last_crash;
/** To prevent using nitro in too short bursts */
float m_min_nitro_time;
void updatePhysics(float dt);
void handleMaterialSFX(const Material *material);
void handleMaterialGFX();