1) Removed references to wheelie and jump kart control structure.
2) Config files will now use nitro/drift instead of wheelie/jump. Old config files will automatically be updated (and a message be printed). 3) Renamed all members of the kart control structure to start with m_ . git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@2737 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
94468c7425
commit
1c81e0f664
@ -84,7 +84,7 @@ void SkidMarks::update(float dt)
|
||||
// delta is 0, and the behaviour is undefined. In this case
|
||||
// just stop doing skid marks as well.
|
||||
// ---------------------------------------------------------
|
||||
if(!raycast_right.m_isInContact || !m_kart.getControls().jump ||
|
||||
if(!raycast_right.m_isInContact || !m_kart.getControls().m_drift ||
|
||||
delta.length2()<0.0001)
|
||||
{
|
||||
m_skid_marking = false;
|
||||
@ -108,7 +108,7 @@ void SkidMarks::update(float dt)
|
||||
}
|
||||
// Currently no skid marking
|
||||
// -------------------------
|
||||
if(!m_kart.getControls().jump) return; // no skidmarking
|
||||
if(!m_kart.getControls().m_drift) return; // no skidmarking
|
||||
|
||||
// Start new skid marks
|
||||
// --------------------
|
||||
|
@ -39,8 +39,8 @@ enum WidgetTokens
|
||||
WTOK_RIGHT,
|
||||
WTOK_ACCEL,
|
||||
WTOK_BRAKE,
|
||||
WTOK_WHEELIE,
|
||||
WTOK_JUMP,
|
||||
WTOK_NITRO,
|
||||
WTOK_DRIFT,
|
||||
WTOK_RESCUE,
|
||||
WTOK_FIRE,
|
||||
WTOK_LOOK_BACK,
|
||||
|
@ -182,8 +182,8 @@ void History::Save()
|
||||
// FIXME: kart number is not really necessary
|
||||
fprintf(fd, "%d %f %f %d %f %f %f %f %f %f %f\n",
|
||||
k,
|
||||
m_all_controls[j].lr,
|
||||
m_all_controls[j].accel,
|
||||
m_all_controls[j].m_steer,
|
||||
m_all_controls[j].m_accel,
|
||||
m_all_controls[j].getButtonsCompressed(),
|
||||
m_all_xyz[j].getX(), m_all_xyz[j].getY(),
|
||||
m_all_xyz[j].getZ(),
|
||||
@ -293,8 +293,8 @@ void History::Load()
|
||||
float x,y,z,rx,ry,rz,rw;
|
||||
sscanf(s, "%d %f %f %d %f %f %f %f %f %f %f\n",
|
||||
&j,
|
||||
&m_all_controls[i].lr,
|
||||
&m_all_controls[i].accel,
|
||||
&m_all_controls[i].m_steer,
|
||||
&m_all_controls[i].m_accel,
|
||||
&buttonsCompressed,
|
||||
&x, &y, &z, &rx, &ry, &rz, &rw);
|
||||
m_all_xyz[i] = Vec3(x,y,z);
|
||||
|
@ -90,8 +90,8 @@ enum KartAction {
|
||||
KA_RIGHT,
|
||||
KA_ACCEL,
|
||||
KA_BRAKE,
|
||||
KA_WHEELIE,
|
||||
KA_JUMP,
|
||||
KA_NITRO,
|
||||
KA_DRIFT,
|
||||
KA_RESCUE,
|
||||
KA_FIRE,
|
||||
KA_LOOK_BACK
|
||||
@ -132,8 +132,8 @@ enum GameAction
|
||||
GA_P1_RIGHT,
|
||||
GA_P1_ACCEL,
|
||||
GA_P1_BRAKE,
|
||||
GA_P1_WHEELIE,
|
||||
GA_P1_JUMP,
|
||||
GA_P1_NITRO,
|
||||
GA_P1_DRIFT,
|
||||
GA_P1_RESCUE,
|
||||
GA_P1_FIRE,
|
||||
GA_P1_LOOK_BACK,
|
||||
@ -142,8 +142,8 @@ enum GameAction
|
||||
GA_P2_RIGHT,
|
||||
GA_P2_ACCEL,
|
||||
GA_P2_BRAKE,
|
||||
GA_P2_WHEELIE,
|
||||
GA_P2_JUMP,
|
||||
GA_P2_NITRO,
|
||||
GA_P2_DRIFT,
|
||||
GA_P2_RESCUE,
|
||||
GA_P2_FIRE,
|
||||
GA_P2_LOOK_BACK,
|
||||
@ -152,8 +152,8 @@ enum GameAction
|
||||
GA_P3_RIGHT,
|
||||
GA_P3_ACCEL,
|
||||
GA_P3_BRAKE,
|
||||
GA_P3_WHEELIE,
|
||||
GA_P3_JUMP,
|
||||
GA_P3_NITRO,
|
||||
GA_P3_DRIFT,
|
||||
GA_P3_RESCUE,
|
||||
GA_P3_FIRE,
|
||||
GA_P3_LOOK_BACK,
|
||||
@ -162,8 +162,8 @@ enum GameAction
|
||||
GA_P4_RIGHT,
|
||||
GA_P4_ACCEL,
|
||||
GA_P4_BRAKE,
|
||||
GA_P4_WHEELIE,
|
||||
GA_P4_JUMP,
|
||||
GA_P4_NITRO,
|
||||
GA_P4_DRIFT,
|
||||
GA_P4_RESCUE,
|
||||
GA_P4_FIRE,
|
||||
GA_P4_LOOK_BACK,
|
||||
|
@ -76,7 +76,6 @@ Kart::Kart (const std::string& kart_name, int position,
|
||||
m_eliminated = false;
|
||||
m_finished_race = false;
|
||||
m_finish_time = 0.0f;
|
||||
m_wheelie_angle = 0.0f;
|
||||
m_smoke_system = NULL;
|
||||
m_nitro = NULL;
|
||||
m_skidmarks = NULL;
|
||||
@ -325,17 +324,16 @@ void Kart::reset()
|
||||
m_zipper_time_left = 0.0f;
|
||||
m_collected_energy = 0;
|
||||
m_wheel_rotation = 0;
|
||||
m_wheelie_angle = 0.0f;
|
||||
m_bounce_back_time = 0.0f;
|
||||
m_skidding = 1.0f;
|
||||
m_time_last_crash = 0.0f;
|
||||
|
||||
m_controls.lr = 0.0f;
|
||||
m_controls.accel = 0.0f;
|
||||
m_controls.brake = false;
|
||||
m_controls.wheelie = false;
|
||||
m_controls.jump = false;
|
||||
m_controls.fire = false;
|
||||
m_controls.m_steer = 0.0f;
|
||||
m_controls.m_accel = 0.0f;
|
||||
m_controls.m_brake = false;
|
||||
m_controls.m_nitro = false;
|
||||
m_controls.m_drift = false;
|
||||
m_controls.m_fire = false;
|
||||
|
||||
// Set the brakes so that karts don't slide downhill
|
||||
for(int i=0; i<4; i++) m_vehicle->setBrake(5.0f, i);
|
||||
@ -377,9 +375,7 @@ void Kart::collectedItem(const Item &item, int add_info)
|
||||
{
|
||||
// In wheelie style, karts get more items depending on energy,
|
||||
// in nitro mode it's only one item.
|
||||
int n = (int)(stk_config->m_game_style==STKConfig::GS_WHEELIE
|
||||
? 1 + 4*getEnergy() / MAX_ITEMS_COLLECTED
|
||||
: 1);
|
||||
int n = 1;
|
||||
m_powerup.hitBonusBox(n, item,add_info);
|
||||
break;
|
||||
}
|
||||
@ -479,13 +475,13 @@ void Kart::update(float dt)
|
||||
}
|
||||
|
||||
// On a client fiering is done upon receiving the command from the server.
|
||||
if ( m_controls.fire && network_manager->getMode()!=NetworkManager::NW_CLIENT
|
||||
if ( m_controls.m_fire && network_manager->getMode()!=NetworkManager::NW_CLIENT
|
||||
&& !isRescue())
|
||||
{
|
||||
// use() needs to be called even if there currently is no collecteable
|
||||
// since use() can test if something needs to be switched on/off.
|
||||
m_powerup.use() ;
|
||||
m_controls.fire = false;
|
||||
m_controls.m_fire = false;
|
||||
}
|
||||
|
||||
// Only use the upright constraint if the kart is in the air!
|
||||
@ -596,7 +592,7 @@ void Kart::update(float dt)
|
||||
void Kart::handleZipper()
|
||||
{
|
||||
// Ignore a zipper that's activated while braking
|
||||
if(m_controls.brake) return;
|
||||
if(m_controls.m_brake) return;
|
||||
m_zipper_time_left = stk_config->m_zipper_time;
|
||||
const btVector3& v = m_body->getLinearVelocity();
|
||||
float current_speed = v.length();
|
||||
@ -638,7 +634,7 @@ void Kart::draw()
|
||||
*/
|
||||
float Kart::handleNitro(float dt)
|
||||
{
|
||||
if(!m_controls.wheelie) return 0.0;
|
||||
if(!m_controls.m_nitro) return 0.0;
|
||||
m_collected_energy -= dt;
|
||||
if(m_collected_energy<0)
|
||||
{
|
||||
@ -696,7 +692,7 @@ void Kart::updatePhysics (float dt)
|
||||
float engine_power = getActualWheelForce() + handleNitro(dt);
|
||||
if(m_attachment.getType()==ATTACH_PARACHUTE) engine_power*=0.2f;
|
||||
|
||||
if(m_controls.accel) // accelerating
|
||||
if(m_controls.m_accel) // accelerating
|
||||
{ // For a short time after a collision disable the engine,
|
||||
// so that the karts can bounce back a bit from the obstacle.
|
||||
if(m_bounce_back_time>0.0f) engine_power = 0.0f;
|
||||
@ -715,7 +711,7 @@ void Kart::updatePhysics (float dt)
|
||||
}
|
||||
else
|
||||
{ // not accelerating
|
||||
if(m_controls.brake)
|
||||
if(m_controls.m_brake)
|
||||
{ // check if the player is currently only slowing down or moving backwards
|
||||
if(m_speed > 0.0f)
|
||||
{ // going forward
|
||||
@ -733,7 +729,7 @@ void Kart::updatePhysics (float dt)
|
||||
// going backward, apply reverse gear ratio (unless he goes too fast backwards)
|
||||
if ( fabs(m_speed) < m_max_speed*m_max_speed_reverse_ratio )
|
||||
{
|
||||
if(m_controls.brake)
|
||||
if(m_controls.m_brake)
|
||||
{
|
||||
// the backwards acceleration is artificially increased to allow
|
||||
// players to get "unstuck" quicker if they hit e.g. a wall
|
||||
@ -752,8 +748,8 @@ void Kart::updatePhysics (float dt)
|
||||
else
|
||||
{
|
||||
// lift the foot from throttle, brakes with 10% engine_power
|
||||
m_vehicle->applyEngineForce(-m_controls.accel*engine_power*0.1f, 2);
|
||||
m_vehicle->applyEngineForce(-m_controls.accel*engine_power*0.1f, 3);
|
||||
m_vehicle->applyEngineForce(-m_controls.m_accel*engine_power*0.1f, 2);
|
||||
m_vehicle->applyEngineForce(-m_controls.m_accel*engine_power*0.1f, 3);
|
||||
|
||||
if(!RaceManager::getWorld()->isStartPhase())
|
||||
resetBrakes();
|
||||
@ -771,39 +767,30 @@ void Kart::updatePhysics (float dt)
|
||||
|
||||
}
|
||||
#endif
|
||||
if(m_wheelie_angle<=0.0f)
|
||||
if(m_controls.m_drift)
|
||||
{
|
||||
|
||||
if(m_controls.jump)
|
||||
{
|
||||
m_skidding*= m_kart_properties->getSkidIncrease();
|
||||
if(m_skidding>m_kart_properties->getMaxSkid())
|
||||
m_skidding=m_kart_properties->getMaxSkid();
|
||||
}
|
||||
else if(m_skidding>1.0f)
|
||||
{
|
||||
m_skidding *= m_kart_properties->getSkidDecrease();
|
||||
if(m_skidding<1.0f) m_skidding=1.0f;
|
||||
}
|
||||
if(m_skidding>1.0f)
|
||||
{
|
||||
if(m_skid_sound->getStatus() != SFXManager::SFX_PLAYING)
|
||||
m_skid_sound->play();
|
||||
}
|
||||
else if(m_skid_sound->getStatus() == SFXManager::SFX_PLAYING)
|
||||
{
|
||||
m_skid_sound->stop();
|
||||
}
|
||||
float steering = getMaxSteerAngle() * m_controls.lr*m_skidding;
|
||||
|
||||
m_vehicle->setSteeringValue(steering, 0);
|
||||
m_vehicle->setSteeringValue(steering, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_vehicle->setSteeringValue(0.0f, 0);
|
||||
m_vehicle->setSteeringValue(0.0f, 1);
|
||||
m_skidding*= m_kart_properties->getSkidIncrease();
|
||||
if(m_skidding>m_kart_properties->getMaxSkid())
|
||||
m_skidding=m_kart_properties->getMaxSkid();
|
||||
}
|
||||
else if(m_skidding>1.0f)
|
||||
{
|
||||
m_skidding *= m_kart_properties->getSkidDecrease();
|
||||
if(m_skidding<1.0f) m_skidding=1.0f;
|
||||
}
|
||||
if(m_skidding>1.0f)
|
||||
{
|
||||
if(m_skid_sound->getStatus() != SFXManager::SFX_PLAYING)
|
||||
m_skid_sound->play();
|
||||
}
|
||||
else if(m_skid_sound->getStatus() == SFXManager::SFX_PLAYING)
|
||||
{
|
||||
m_skid_sound->stop();
|
||||
}
|
||||
float steering = getMaxSteerAngle() * m_controls.m_steer*m_skidding;
|
||||
|
||||
m_vehicle->setSteeringValue(steering, 0);
|
||||
m_vehicle->setSteeringValue(steering, 1);
|
||||
|
||||
// Only compute the current speed if this is not the client. On a client the
|
||||
// speed is actually received from the server.
|
||||
@ -959,7 +946,7 @@ void Kart::updateGraphics(const Vec3& off_xyz, const Vec3& off_hpr)
|
||||
wheel_z_axis[i] = m_default_suspension_length[i]
|
||||
- m_vehicle->getWheelInfo(i).m_raycastInfo.m_suspensionLength;
|
||||
}
|
||||
kart_model->adjustWheels(m_wheel_rotation, m_controls.lr*30.0f,
|
||||
kart_model->adjustWheels(m_wheel_rotation, m_controls.m_steer*30.0f,
|
||||
wheel_z_axis);
|
||||
|
||||
Vec3 center_shift = getGravityCenterShift();
|
||||
@ -967,24 +954,22 @@ void Kart::updateGraphics(const Vec3& off_xyz, const Vec3& off_hpr)
|
||||
- m_default_suspension_length[0]
|
||||
- m_vehicle->getWheelInfo(0).m_wheelsRadius
|
||||
- (kart_model->getWheelGraphicsRadius(0)
|
||||
-kart_model->getWheelGraphicsPosition(0).getZ() )
|
||||
+ getKartLength()*0.5f*fabs(sin(DEGREE_TO_RAD(m_wheelie_angle)));
|
||||
-kart_model->getWheelGraphicsPosition(0).getZ() );
|
||||
center_shift.setZ(X);
|
||||
const float offset_pitch = DEGREE_TO_RAD(m_wheelie_angle);
|
||||
|
||||
if(m_smoke_system)
|
||||
{
|
||||
float f = fabsf(m_controls.lr) > 0.8 ? 50.0f : 0.0f;
|
||||
float f = fabsf(m_controls.m_steer) > 0.8 ? 50.0f : 0.0f;
|
||||
m_smoke_system->setCreationRate((m_skidding-1)*f);
|
||||
}
|
||||
if(m_nitro)
|
||||
m_nitro->setCreationRate(m_controls.wheelie && m_collected_energy>0
|
||||
m_nitro->setCreationRate(m_controls.m_nitro && m_collected_energy>0
|
||||
? getSpeed()*5.0f : 0);
|
||||
|
||||
float speed_ratio = getSpeed()/getMaxSpeed();
|
||||
float offset_heading = getSteerPercent()*m_kart_properties->getSkidVisual()
|
||||
* speed_ratio * m_skidding*m_skidding;
|
||||
Moveable::updateGraphics(center_shift, Vec3(offset_heading, offset_pitch, 0));
|
||||
Moveable::updateGraphics(center_shift, Vec3(offset_heading, 0, 0));
|
||||
} // updateGraphics
|
||||
|
||||
/* EOF */
|
||||
|
@ -57,7 +57,6 @@ protected:
|
||||
float m_max_speed; // maximum speed of the kart, computed from
|
||||
float m_max_gear_rpm; //maximum engine rpm's for the current gear
|
||||
float m_max_speed_reverse_ratio;
|
||||
float m_wheelie_angle;
|
||||
float m_zipper_time_left; // zipper time left
|
||||
float m_bounce_back_time; // a short time after a collision acceleration
|
||||
// is disabled to allow the karts to bounce back
|
||||
@ -168,7 +167,7 @@ public:
|
||||
{return m_kart_properties->getMaxSteerAngle(getSpeed());}
|
||||
const Vec3& getGravityCenterShift () const
|
||||
{return m_kart_properties->getGravityCenterShift(); }
|
||||
float getSteerPercent () const {return m_controls.lr; }
|
||||
float getSteerPercent () const {return m_controls.m_steer; }
|
||||
const KartControl&
|
||||
getControls () const {return m_controls; }
|
||||
/** Sets the kart controls. Used e.g. by replaying history. */
|
||||
@ -180,7 +179,6 @@ public:
|
||||
/** Returns the height of the kart. */
|
||||
float getKartHeight () const
|
||||
{return m_kart_properties->getKartModel()->getHeight(); }
|
||||
float getWheelieAngle () const {return m_wheelie_angle; }
|
||||
btKart *getVehicle () const {return m_vehicle; }
|
||||
btUprightConstraint *getUprightConstraint() const {return m_uprightConstraint;}
|
||||
void createPhysics ();
|
||||
|
@ -25,31 +25,31 @@
|
||||
class KartControl
|
||||
{
|
||||
public:
|
||||
float lr;
|
||||
float accel;
|
||||
bool brake;
|
||||
bool wheelie;
|
||||
bool jump;
|
||||
bool rescue;
|
||||
bool fire;
|
||||
float m_steer;
|
||||
float m_accel;
|
||||
bool m_brake;
|
||||
bool m_nitro;
|
||||
bool m_drift;
|
||||
bool m_rescue;
|
||||
bool m_fire;
|
||||
|
||||
KartControl() : lr(0.0f), accel(0.0f), brake(false),
|
||||
wheelie(false), jump(false), rescue(false),
|
||||
fire(false)
|
||||
KartControl() : m_steer(0.0f), m_accel(0.0f), m_brake(false),
|
||||
m_nitro(false), m_drift(false), m_rescue(false),
|
||||
m_fire(false)
|
||||
{
|
||||
}
|
||||
// ------------------------------------------------------------------------
|
||||
/** Construct kart control from a Message (i.e. unserialise) */
|
||||
KartControl(Message *m)
|
||||
{
|
||||
lr = m->getFloat();
|
||||
accel = m->getFloat();
|
||||
char c = m->getChar();
|
||||
brake = (c & 1) != 0;
|
||||
wheelie = (c & 2) != 0;
|
||||
jump = (c & 4) != 0;
|
||||
rescue = (c & 8) != 0;
|
||||
fire = (c & 16) != 0;
|
||||
m_steer = m->getFloat();
|
||||
m_accel = m->getFloat();
|
||||
char c = m->getChar();
|
||||
m_brake = (c & 1) != 0;
|
||||
m_nitro = (c & 2) != 0;
|
||||
m_drift = (c & 4) != 0;
|
||||
m_rescue = (c & 8) != 0;
|
||||
m_fire = (c & 16) != 0;
|
||||
} // KartControl(Message*)
|
||||
// ------------------------------------------------------------------------
|
||||
/** Return the serialised size in bytes. */
|
||||
@ -58,26 +58,26 @@ public:
|
||||
/** Serialises the kart control into a message. */
|
||||
void serialise(Message *m) const
|
||||
{
|
||||
m->addFloat(lr);
|
||||
m->addFloat(accel);
|
||||
m->addFloat(m_steer);
|
||||
m->addFloat(m_accel);
|
||||
m->addChar(getButtonsCompressed());
|
||||
} // compress
|
||||
// ------------------------------------------------------------------------
|
||||
void uncompress(char *c)
|
||||
{
|
||||
lr = ((float*)c)[0];
|
||||
accel = ((float*)c)[1];
|
||||
m_steer = ((float*)c)[0];
|
||||
m_accel = ((float*)c)[1];
|
||||
setButtonsCompressed(c[8]);
|
||||
} // uncompress
|
||||
// ------------------------------------------------------------------------
|
||||
/** Compresses all buttons into a single integer value. */
|
||||
char getButtonsCompressed() const
|
||||
{
|
||||
return brake ? 1 : 0
|
||||
+ wheelie ? 2 : 0
|
||||
+ jump ? 4 : 0
|
||||
+ rescue ? 8 : 0
|
||||
+ fire ? 16 : 0;
|
||||
return m_brake ? 1 : 0
|
||||
+ m_nitro ? 2 : 0
|
||||
+ m_drift ? 4 : 0
|
||||
+ m_rescue ? 8 : 0
|
||||
+ m_fire ? 16 : 0;
|
||||
} // getButtonsCompressed
|
||||
// ------------------------------------------------------------------------
|
||||
/** Sets the buttons from a compressed representation.
|
||||
@ -85,11 +85,11 @@ public:
|
||||
*/
|
||||
void setButtonsCompressed(char c)
|
||||
{
|
||||
brake = (c & 1) != 0;
|
||||
wheelie = (c & 2) != 0;
|
||||
jump = (c & 4) != 0;
|
||||
rescue = (c & 8) != 0;
|
||||
fire = (c & 16) != 0;
|
||||
m_brake = (c & 1) != 0;
|
||||
m_nitro = (c & 2) != 0;
|
||||
m_drift = (c & 4) != 0;
|
||||
m_rescue = (c & 8) != 0;
|
||||
m_fire = (c & 16) != 0;
|
||||
} // setButtonsCompressed
|
||||
};
|
||||
|
||||
|
@ -65,14 +65,9 @@ PlayerKart::~PlayerKart()
|
||||
//-----------------------------------------------------------------------------
|
||||
void PlayerKart::reset()
|
||||
{
|
||||
m_steer_val_l = 0;
|
||||
m_steer_val_r = 0;
|
||||
m_steer_val = 0;
|
||||
m_controls.accel = 0.0;
|
||||
m_controls.brake =false;
|
||||
m_controls.fire = false;
|
||||
m_controls.wheelie = false;
|
||||
m_controls.jump = false;
|
||||
m_steer_val_l = 0;
|
||||
m_steer_val_r = 0;
|
||||
m_steer_val = 0;
|
||||
m_penalty_time = 0;
|
||||
Kart::reset();
|
||||
m_camera->reset();
|
||||
@ -100,27 +95,27 @@ void PlayerKart::action(KartAction action, int value)
|
||||
|
||||
break;
|
||||
case KA_ACCEL:
|
||||
m_controls.accel = value/32768.0f;
|
||||
m_controls.m_accel = value/32768.0f;
|
||||
break;
|
||||
case KA_BRAKE:
|
||||
if (value)
|
||||
m_controls.accel = 0;
|
||||
m_controls.brake = (value!=0); // This syntax avoid visual c++ warning (when brake=value)
|
||||
m_controls.m_accel = 0;
|
||||
m_controls.m_brake = (value!=0); // This syntax avoid visual c++ warning (when brake=value)
|
||||
break;
|
||||
case KA_WHEELIE:
|
||||
m_controls.wheelie = (value!=0);
|
||||
case KA_NITRO:
|
||||
m_controls.m_nitro = (value!=0);
|
||||
break;
|
||||
case KA_RESCUE:
|
||||
m_controls.rescue = (value!=0);
|
||||
m_controls.m_rescue = (value!=0);
|
||||
break;
|
||||
case KA_FIRE:
|
||||
m_controls.fire = (value!=0);
|
||||
m_controls.m_fire = (value!=0);
|
||||
break;
|
||||
case KA_LOOK_BACK:
|
||||
m_camera->setMode(value!=0 ? Camera::CM_REVERSE : Camera::CM_NORMAL);
|
||||
break;
|
||||
case KA_JUMP:
|
||||
m_controls.jump = (value!=0);
|
||||
case KA_DRIFT:
|
||||
m_controls.m_drift = (value!=0);
|
||||
break;
|
||||
}
|
||||
} // action
|
||||
@ -133,33 +128,33 @@ void PlayerKart::steer(float dt, int steer_val)
|
||||
{
|
||||
// If we got analog values do not cumulate.
|
||||
if (steer_val > -32767)
|
||||
m_controls.lr = -steer_val/32767.0f;
|
||||
m_controls.m_steer = -steer_val/32767.0f;
|
||||
else
|
||||
m_controls.lr += STEER_CHANGE;
|
||||
m_controls.m_steer += STEER_CHANGE;
|
||||
}
|
||||
else if(steer_val > 0)
|
||||
{
|
||||
// If we got analog values do not cumulate.
|
||||
if (steer_val < 32767)
|
||||
m_controls.lr = -steer_val/32767.0f;
|
||||
m_controls.m_steer = -steer_val/32767.0f;
|
||||
else
|
||||
m_controls.lr -= STEER_CHANGE;
|
||||
m_controls.m_steer -= STEER_CHANGE;
|
||||
}
|
||||
else
|
||||
{ // no key is pressed
|
||||
if(m_controls.lr>0.0f)
|
||||
if(m_controls.m_steer>0.0f)
|
||||
{
|
||||
m_controls.lr -= STEER_CHANGE;
|
||||
if(m_controls.lr<0.0f) m_controls.lr=0.0f;
|
||||
m_controls.m_steer -= STEER_CHANGE;
|
||||
if(m_controls.m_steer<0.0f) m_controls.m_steer=0.0f;
|
||||
}
|
||||
else
|
||||
{ // m_controls.lr<=0.0f;
|
||||
m_controls.lr += STEER_CHANGE;
|
||||
if(m_controls.lr>0.0f) m_controls.lr=0.0f;
|
||||
} // if m_controls.lr<=0.0f
|
||||
{ // m_controls.m_steer<=0.0f;
|
||||
m_controls.m_steer += STEER_CHANGE;
|
||||
if(m_controls.m_steer>0.0f) m_controls.m_steer=0.0f;
|
||||
} // if m_controls.m_steer<=0.0f
|
||||
} // no key is pressed
|
||||
|
||||
m_controls.lr = std::min(1.0f, std::max(-1.0f, m_controls.lr));
|
||||
m_controls.m_steer = std::min(1.0f, std::max(-1.0f, m_controls.m_steer));
|
||||
|
||||
} // steer
|
||||
|
||||
@ -174,8 +169,8 @@ void PlayerKart::update(float dt)
|
||||
|
||||
if(RaceManager::getWorld()->isStartPhase())
|
||||
{
|
||||
if(m_controls.accel!=0.0 || m_controls.brake!=false ||
|
||||
m_controls.fire|m_controls.wheelie|m_controls.jump)
|
||||
if(m_controls.m_accel!=0.0 || m_controls.m_brake!=false ||
|
||||
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
|
||||
{
|
||||
@ -200,7 +195,7 @@ void PlayerKart::update(float dt)
|
||||
return;
|
||||
}
|
||||
|
||||
if ( m_controls.fire && !isRescue())
|
||||
if ( m_controls.m_fire && !isRescue())
|
||||
{
|
||||
if (m_powerup.getType()==POWERUP_NOTHING)
|
||||
Kart::beep();
|
||||
@ -209,11 +204,11 @@ void PlayerKart::update(float dt)
|
||||
// We can't restrict rescue to fulfil isOnGround() (which would be more like
|
||||
// MK), since e.g. in the City track it is possible for the kart to end
|
||||
// up sitting on a brick wall, with all wheels in the air :((
|
||||
if ( m_controls.rescue )
|
||||
if ( m_controls.m_rescue )
|
||||
{
|
||||
//m_beep_sound->play();
|
||||
forceRescue();
|
||||
m_controls.rescue=false;
|
||||
m_controls.m_rescue=false;
|
||||
}
|
||||
// FIXME: This is the code previously done in Kart::update (for player
|
||||
// karts). Does this mean that there are actually two sounds played
|
||||
|
@ -125,7 +125,7 @@ void RaceState::receive(ENetPacket *pkt)
|
||||
Kart *kart = RaceManager::getKart(i);
|
||||
// Firing needs to be done from here to guarantee that any potential
|
||||
// new rockets are created before the update for the rockets is handled
|
||||
if(kc.fire)
|
||||
if(kc.m_fire)
|
||||
kart->getPowerup()->use();
|
||||
kart->setXYZ(xyz);
|
||||
kart->setRotation(q);
|
||||
|
@ -183,7 +183,7 @@ void DefaultRobot::handleBraking()
|
||||
getPosition() < RaceManager::getKart(0)->getPosition() &&
|
||||
getInitialPosition()>1 )
|
||||
{
|
||||
m_controls.brake = true;
|
||||
m_controls.m_brake = true;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -212,7 +212,7 @@ void DefaultRobot::handleBraking()
|
||||
if(!(m_world->getDistanceToCenterForKart(getWorldKartId()) > m_track->getWidth()[m_track_sector] *
|
||||
-CURVE_INSIDE_PERC || m_curve_angle > RAD_TO_DEGREE(getMaxSteerAngle())))
|
||||
{
|
||||
m_controls.brake = false;
|
||||
m_controls.m_brake = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -221,7 +221,7 @@ void DefaultRobot::handleBraking()
|
||||
if(!(m_world->getDistanceToCenterForKart( getWorldKartId() ) < m_track->getWidth()[m_track_sector] *
|
||||
CURVE_INSIDE_PERC || m_curve_angle < -RAD_TO_DEGREE(getMaxSteerAngle())))
|
||||
{
|
||||
m_controls.brake = false;
|
||||
m_controls.m_brake = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -235,13 +235,13 @@ void DefaultRobot::handleBraking()
|
||||
#ifdef AI_DEBUG
|
||||
std::cout << "BRAKING" << std::endl;
|
||||
#endif
|
||||
m_controls.brake = true;
|
||||
m_controls.m_brake = true;
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
m_controls.brake = false;
|
||||
m_controls.m_brake = false;
|
||||
} // handleBraking
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -345,7 +345,7 @@ void DefaultRobot::handleSteering(float dt)
|
||||
//-----------------------------------------------------------------------------
|
||||
void DefaultRobot::handleItems( const float DELTA, const int STEPS )
|
||||
{
|
||||
m_controls.fire = false;
|
||||
m_controls.m_fire = false;
|
||||
|
||||
if(isRescue() )
|
||||
{
|
||||
@ -360,7 +360,7 @@ void DefaultRobot::handleItems( const float DELTA, const int STEPS )
|
||||
case IT_TEN_SECONDS:
|
||||
if( m_time_since_last_shot > 10.0f )
|
||||
{
|
||||
m_controls.fire = true;
|
||||
m_controls.m_fire = true;
|
||||
m_time_since_last_shot = 0.0f;
|
||||
}
|
||||
break;
|
||||
@ -376,7 +376,7 @@ void DefaultRobot::handleItems( const float DELTA, const int STEPS )
|
||||
if( m_time_since_last_shot > 10.0f && ANGLE_DIFF <
|
||||
15.0f && !m_crashes.m_road && STEPS > 8 )
|
||||
{
|
||||
m_controls.fire = true;
|
||||
m_controls.m_fire = true;
|
||||
m_time_since_last_shot = 0.0f;
|
||||
}
|
||||
}
|
||||
@ -389,7 +389,7 @@ void DefaultRobot::handleItems( const float DELTA, const int STEPS )
|
||||
if( (getXYZ()-RaceManager::getKart(m_crashes.m_kart)->getXYZ() ).length_2d() >
|
||||
m_kart_length * 2.5f )
|
||||
{
|
||||
m_controls.fire = true;
|
||||
m_controls.m_fire = true;
|
||||
m_time_since_last_shot = 0.0f;
|
||||
}
|
||||
}
|
||||
@ -399,12 +399,12 @@ void DefaultRobot::handleItems( const float DELTA, const int STEPS )
|
||||
case POWERUP_PLUNGER:
|
||||
if ( m_time_since_last_shot > 3.0f && m_crashes.m_kart != -1 )
|
||||
{
|
||||
m_controls.fire = true;
|
||||
m_controls.m_fire = true;
|
||||
m_time_since_last_shot = 0.0f;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
m_controls.fire = true;
|
||||
m_controls.m_fire = true;
|
||||
m_time_since_last_shot = 0.0f;
|
||||
return;
|
||||
}
|
||||
@ -421,13 +421,13 @@ void DefaultRobot::handleAcceleration( const float DELTA )
|
||||
if( m_time_till_start > 0.0f )
|
||||
{
|
||||
m_time_till_start -= DELTA;
|
||||
m_controls.accel = 0.0f;
|
||||
m_controls.m_accel = 0.0f;
|
||||
return;
|
||||
}
|
||||
|
||||
if( m_controls.brake == true )
|
||||
if( m_controls.m_brake == true )
|
||||
{
|
||||
m_controls.accel = 0.0f;
|
||||
m_controls.m_accel = 0.0f;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -444,12 +444,12 @@ void DefaultRobot::handleAcceleration( const float DELTA )
|
||||
|
||||
if( player_winning )
|
||||
{
|
||||
m_controls.accel = m_max_handicap_accel;
|
||||
m_controls.m_accel = m_max_handicap_accel;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
m_controls.accel = 1.0f;
|
||||
m_controls.m_accel = 1.0f;
|
||||
} // handleAcceleration
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -492,7 +492,7 @@ void DefaultRobot::handleRescue(const float DELTA)
|
||||
*/
|
||||
void DefaultRobot::handleNitro()
|
||||
{
|
||||
m_controls.wheelie = false;
|
||||
m_controls.m_nitro = false;
|
||||
// Don't use nitro if the kart doesn't have any, is not on ground,
|
||||
if(getEnergy()==0 || !isOnGround() ||
|
||||
m_nitro_level==NITRO_NONE || hasFinishedRace() ) return;
|
||||
@ -507,7 +507,7 @@ void DefaultRobot::handleNitro()
|
||||
// If the kart is very slow (e.g. after rescue), use nitro
|
||||
if(getSpeed()<5)
|
||||
{
|
||||
m_controls.wheelie = true;
|
||||
m_controls.m_nitro = true;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -517,7 +517,7 @@ void DefaultRobot::handleNitro()
|
||||
const unsigned int num_karts = race_manager->getNumKarts();
|
||||
if(getPosition()== (int)num_karts && getEnergy()>2.0f)
|
||||
{
|
||||
m_controls.wheelie = true;
|
||||
m_controls.m_nitro = true;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -530,7 +530,7 @@ void DefaultRobot::handleNitro()
|
||||
float finish = m_world->getEstimatedFinishTime(getWorldKartId());
|
||||
if( 1.3f*getEnergy() >= finish - m_world->getTime() )
|
||||
{
|
||||
m_controls.wheelie = true;
|
||||
m_controls.m_nitro = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -560,7 +560,7 @@ void DefaultRobot::handleNitro()
|
||||
if(kart->getSpeed() < getSpeed()) continue;
|
||||
|
||||
// Only prevent overtaking on highest level
|
||||
m_controls.wheelie = m_nitro_level==NITRO_ALL;
|
||||
m_controls.m_nitro = m_nitro_level==NITRO_ALL;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -568,7 +568,7 @@ void DefaultRobot::handleNitro()
|
||||
// -----------------------------------------------
|
||||
if(kart->getSpeed()+5.0f > getSpeed())
|
||||
{
|
||||
m_controls.wheelie = true;
|
||||
m_controls.m_nitro = true;
|
||||
}
|
||||
}
|
||||
} // handleNitro
|
||||
@ -886,7 +886,7 @@ int DefaultRobot::calcSteps()
|
||||
|
||||
//Increase the steps depending on the width, if we steering hard,
|
||||
//mostly for curves.
|
||||
if( fabsf(m_controls.lr) > 0.95 )
|
||||
if( fabsf(m_controls.m_steer) > 0.95 )
|
||||
{
|
||||
const int WIDTH_STEPS =
|
||||
(int)( m_track->getWidth()[m_future_sector]
|
||||
@ -912,23 +912,23 @@ int DefaultRobot::calcSteps()
|
||||
void DefaultRobot::setSteering(float angle, float dt)
|
||||
{
|
||||
float steer_fraction = angle / getMaxSteerAngle();
|
||||
m_controls.jump = fabsf(steer_fraction)>=m_skidding_threshold;
|
||||
float old_lr = m_controls.lr;
|
||||
m_controls.m_drift = fabsf(steer_fraction)>=m_skidding_threshold;
|
||||
float old_steer = m_controls.m_steer;
|
||||
|
||||
if (steer_fraction > 1.0f) steer_fraction = 1.0f;
|
||||
else if(steer_fraction < -1.0f) steer_fraction = -1.0f;
|
||||
|
||||
// The AI has its own 'time full steer' value (which is the time
|
||||
float max_steer_change = dt/m_kart_properties->getTimeFullSteerAI();
|
||||
if(old_lr < steer_fraction)
|
||||
if(old_steer < steer_fraction)
|
||||
{
|
||||
m_controls.lr = (old_lr+max_steer_change > steer_fraction)
|
||||
? steer_fraction : old_lr+max_steer_change;
|
||||
m_controls.m_steer = (old_steer+max_steer_change > steer_fraction)
|
||||
? steer_fraction : old_steer+max_steer_change;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_controls.lr = (old_lr-max_steer_change < steer_fraction)
|
||||
? steer_fraction : old_lr-max_steer_change;
|
||||
m_controls.m_steer = (old_steer-max_steer_change < steer_fraction)
|
||||
? steer_fraction : old_steer-max_steer_change;
|
||||
}
|
||||
} // setSteering
|
||||
|
||||
|
@ -135,7 +135,6 @@ void STKConfig::init_defaults()
|
||||
m_max_skidmarks = -100;
|
||||
m_title_music = NULL;
|
||||
m_enable_networking = true;
|
||||
m_game_style = GS_WHEELIE;
|
||||
m_scores.clear();
|
||||
m_leader_intervals.clear();
|
||||
} // init_defaults
|
||||
@ -177,19 +176,6 @@ void STKConfig::getAllData(const lisp::Lisp* lisp)
|
||||
std::string title_music;
|
||||
lisp->get("title-music", title_music );
|
||||
m_title_music = new MusicInformation(file_manager->getMusicFile(title_music));
|
||||
std::string style;
|
||||
if(lisp->get("game-style", style))
|
||||
{
|
||||
if(style=="wheelie")
|
||||
m_game_style = GS_WHEELIE;
|
||||
else if(style=="nitro")
|
||||
m_game_style = GS_NITRO;
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "Invalid value of game style: '%s'\n", style.c_str());
|
||||
exit(-1);
|
||||
}
|
||||
} // if game-style
|
||||
|
||||
// Get the default KartProperties
|
||||
// ------------------------------
|
||||
|
@ -71,14 +71,6 @@ public:
|
||||
|
||||
bool m_enable_networking;
|
||||
|
||||
/** Gaming style: in wheelie, karts can do wheelies, collected coins
|
||||
* increase the number of items you get. With nitro, collected coins
|
||||
* can be used as a speed boost (nitro), but no wheelies are possible.
|
||||
*/
|
||||
enum GameStyle {GS_WHEELIE, GS_NITRO};
|
||||
|
||||
GameStyle m_game_style; /**< Gamestyle: wheelies or nitro */
|
||||
|
||||
std::vector<float>
|
||||
m_leader_intervals; /**<Interval in follow the leader till
|
||||
last kart is reomved. */
|
||||
|
@ -215,9 +215,9 @@ void UserConfig::setDefaults()
|
||||
Input(IT_KEYBOARD, SDLK_UP));
|
||||
set(GA_P1_BRAKE,
|
||||
Input(IT_KEYBOARD, SDLK_DOWN));
|
||||
set(GA_P1_WHEELIE,
|
||||
set(GA_P1_NITRO,
|
||||
Input(IT_KEYBOARD, SDLK_RSHIFT));
|
||||
set(GA_P1_JUMP,
|
||||
set(GA_P1_DRIFT,
|
||||
Input(IT_KEYBOARD, SDLK_MINUS));
|
||||
set(GA_P1_RESCUE,
|
||||
Input(IT_KEYBOARD, SDLK_BACKSPACE));
|
||||
@ -235,9 +235,9 @@ void UserConfig::setDefaults()
|
||||
Input(IT_KEYBOARD, SDLK_w));
|
||||
set(GA_P2_BRAKE,
|
||||
Input(IT_KEYBOARD, SDLK_s));
|
||||
set(GA_P2_WHEELIE,
|
||||
set(GA_P2_NITRO,
|
||||
Input(IT_KEYBOARD, SDLK_LSHIFT));
|
||||
set(GA_P2_JUMP,
|
||||
set(GA_P2_DRIFT,
|
||||
Input(IT_KEYBOARD, SDLK_CAPSLOCK));
|
||||
set(GA_P2_RESCUE,
|
||||
Input(IT_KEYBOARD, SDLK_q));
|
||||
@ -255,9 +255,9 @@ void UserConfig::setDefaults()
|
||||
Input(IT_KEYBOARD, SDLK_t));
|
||||
set(GA_P3_BRAKE,
|
||||
Input(IT_KEYBOARD, SDLK_g));
|
||||
set(GA_P3_WHEELIE,
|
||||
set(GA_P3_NITRO,
|
||||
Input(IT_KEYBOARD, SDLK_c));
|
||||
set(GA_P3_JUMP,
|
||||
set(GA_P3_DRIFT,
|
||||
Input(IT_KEYBOARD, SDLK_v));
|
||||
set(GA_P3_RESCUE,
|
||||
Input(IT_KEYBOARD, SDLK_r));
|
||||
@ -275,9 +275,9 @@ void UserConfig::setDefaults()
|
||||
Input(IT_KEYBOARD, SDLK_i));
|
||||
set(GA_P4_BRAKE,
|
||||
Input(IT_KEYBOARD, SDLK_k));
|
||||
set(GA_P4_WHEELIE,
|
||||
set(GA_P4_NITRO,
|
||||
Input(IT_KEYBOARD, SDLK_m));
|
||||
set(GA_P4_JUMP,
|
||||
set(GA_P4_DRIFT,
|
||||
Input(IT_KEYBOARD, SDLK_COMMA));
|
||||
set(GA_P4_RESCUE,
|
||||
Input(IT_KEYBOARD, SDLK_u));
|
||||
@ -362,6 +362,9 @@ void UserConfig::loadConfig(const std::string& filename)
|
||||
return;
|
||||
}
|
||||
|
||||
// In older config files, nitro is still named 'wheelie', and drift is jump
|
||||
std::string nitro_name="nitro";
|
||||
std::string drift_name="drift";
|
||||
try
|
||||
{
|
||||
const lisp::Lisp* lisp = root->getLisp("tuxkart-config");
|
||||
@ -393,6 +396,10 @@ void UserConfig::loadConfig(const std::string& filename)
|
||||
needToAbort=std::max(needToAbort,0);
|
||||
case 4: printf("Added jumping, which invalidates all key bindings.\n");
|
||||
needToAbort=std::max(needToAbort,0);
|
||||
case 6: printf("Added nitro and drifting, removed jumping and wheelie.\n");
|
||||
nitro_name="wheelie";
|
||||
drift_name="jump";
|
||||
needToAbort=std::max(needToAbort,0);
|
||||
case 99: break;
|
||||
default: printf("Config file version '%d' is too old. Discarding your configuration. Sorry. :(\n", configFileVersion);
|
||||
needToAbort=1;
|
||||
@ -503,8 +510,8 @@ void UserConfig::loadConfig(const std::string& filename)
|
||||
readPlayerInput(reader, "right", KA_RIGHT, i);
|
||||
readPlayerInput(reader, "accel", KA_ACCEL, i);
|
||||
readPlayerInput(reader, "brake", KA_BRAKE, i);
|
||||
readPlayerInput(reader, "wheelie", KA_WHEELIE, i);
|
||||
readPlayerInput(reader, "jump", KA_JUMP, i);
|
||||
readPlayerInput(reader, nitro_name, KA_NITRO, i);
|
||||
readPlayerInput(reader, drift_name, KA_DRIFT, i);
|
||||
readPlayerInput(reader, "rescue", KA_RESCUE, i);
|
||||
readPlayerInput(reader, "fire", KA_FIRE, i);
|
||||
readPlayerInput(reader, "lookBack", KA_LOOK_BACK, i);
|
||||
@ -557,14 +564,14 @@ void UserConfig::readStickConfigs(const lisp::Lisp *r)
|
||||
} // readStickConfigs
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
void UserConfig::readPlayerInput(const lisp::Lisp *r, const char *node,
|
||||
void UserConfig::readPlayerInput(const lisp::Lisp *r, const std::string &node,
|
||||
KartAction ka, int playerIndex)
|
||||
{
|
||||
readInput(r, node, (GameAction) (playerIndex * KC_COUNT + ka + GA_P1_LEFT));
|
||||
} // readPlayerInput
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
void UserConfig::readInput(const lisp::Lisp* r, const char *node,
|
||||
void UserConfig::readInput(const lisp::Lisp* r, const std::string &node,
|
||||
GameAction action)
|
||||
{
|
||||
std::string inputTypeName;
|
||||
@ -721,8 +728,8 @@ void UserConfig::saveConfig(const std::string& filename)
|
||||
writePlayerInput(writer, "right\t", KA_RIGHT, i);
|
||||
writePlayerInput(writer, "accel\t", KA_ACCEL, i);
|
||||
writePlayerInput(writer, "brake\t", KA_BRAKE, i);
|
||||
writePlayerInput(writer, "wheelie\t", KA_WHEELIE, i);
|
||||
writePlayerInput(writer, "jump\t", KA_JUMP, i);
|
||||
writePlayerInput(writer, "nitro\t", KA_NITRO, i);
|
||||
writePlayerInput(writer, "drift\t", KA_DRIFT, i);
|
||||
writePlayerInput(writer, "rescue\t", KA_RESCUE, i);
|
||||
writePlayerInput(writer, "fire\t", KA_FIRE, i);
|
||||
writePlayerInput(writer, "lookBack\t", KA_LOOK_BACK, i);
|
||||
|
@ -40,7 +40,7 @@
|
||||
cause an undefined game action now
|
||||
6: Added stick configurations.
|
||||
*/
|
||||
#define CURRENT_CONFIG_VERSION 6
|
||||
#define CURRENT_CONFIG_VERSION 7
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@ -102,7 +102,7 @@ private:
|
||||
void writeStickConfigs(lisp::Writer *);
|
||||
|
||||
void readPlayerInput(const lisp::Lisp *,
|
||||
const char *,
|
||||
const std::string& node,
|
||||
KartAction ka,
|
||||
int);
|
||||
|
||||
@ -113,7 +113,7 @@ private:
|
||||
|
||||
|
||||
void readInput(const lisp::Lisp *,
|
||||
const char *,
|
||||
const std::string &node,
|
||||
GameAction);
|
||||
|
||||
void writeInput(lisp::Writer *,
|
||||
|
Loading…
Reference in New Issue
Block a user