The keyboard sequence: press accel, press brake, release

brake now results in the kart still accelerating (and 
similar sequences work as expected, too).


git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@2803 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
hikerstk 2008-12-28 19:53:27 +00:00
parent 0749b37e80
commit b1698e2cc5
2 changed files with 30 additions and 7 deletions

View File

@ -68,6 +68,8 @@ void PlayerKart::reset()
m_steer_val_l = 0; m_steer_val_l = 0;
m_steer_val_r = 0; m_steer_val_r = 0;
m_steer_val = 0; m_steer_val = 0;
m_prev_brake = 0;
m_prev_accel = 0;
m_penalty_time = 0; m_penalty_time = 0;
Kart::reset(); Kart::reset();
m_camera->reset(); m_camera->reset();
@ -95,12 +97,30 @@ void PlayerKart::action(KartAction action, int value)
break; break;
case KA_ACCEL: case KA_ACCEL:
m_prev_accel = value;
if(value)
{
m_controls.m_accel = value/32768.0f; m_controls.m_accel = value/32768.0f;
m_controls.m_brake = false;
}
else
{
m_controls.m_accel = 0.0f;
m_controls.m_brake = m_prev_brake;
}
break; break;
case KA_BRAKE: case KA_BRAKE:
if (value) m_prev_brake = value!=0;
m_controls.m_accel = 0; if(value)
m_controls.m_brake = (value!=0); // This syntax avoid visual c++ warning (when brake=value) {
m_controls.m_brake = true;
m_controls.m_accel = 0.0f;
}
else
{
m_controls.m_brake = false;
m_controls.m_accel = m_prev_accel/32768.0f;
}
break; break;
case KA_NITRO: case KA_NITRO:
m_controls.m_nitro = (value!=0); m_controls.m_nitro = (value!=0);
@ -118,6 +138,7 @@ void PlayerKart::action(KartAction action, int value)
m_controls.m_drift = (value!=0); m_controls.m_drift = (value!=0);
break; break;
} }
} // action } // action
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -177,8 +198,8 @@ void PlayerKart::update(float dt)
if(RaceManager::getWorld()->isStartPhase()) if(RaceManager::getWorld()->isStartPhase())
{ {
if(m_controls.m_accel!=0.0 || m_controls.m_brake!=false || if(m_controls.m_accel || m_controls.m_brake ||
m_controls.m_fire|m_controls.m_nitro|m_controls.m_drift) m_controls.m_fire || m_controls.m_nitro || m_controls.m_drift)
{ {
if(m_penalty_time == 0.0)//eliminates machine-gun-effect for SOUND_BZZT if(m_penalty_time == 0.0)//eliminates machine-gun-effect for SOUND_BZZT
{ {

View File

@ -35,6 +35,8 @@ class PlayerKart : public Kart
{ {
private: private:
int m_steer_val, m_steer_val_l, m_steer_val_r; int m_steer_val, m_steer_val_l, m_steer_val_r;
int m_prev_accel;
bool m_prev_brake;
Player *m_player; Player *m_player;
float m_penalty_time; float m_penalty_time;