Allow cakes to be fired backwards, to be more consistent with pretty much all other weapons

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@5232 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria 2010-04-21 19:45:24 +00:00
parent 4c755d02c0
commit 05e79fa23a

View File

@ -62,11 +62,12 @@ Cake::Cake (Kart *kart) : Flyable(kart, POWERUP_CAKE)
float pitch = kart->getTerrainPitch(heading);
// Find closest kart in front of the current one
const bool backwards = kart->getControls().m_look_back;
const Kart *closest_kart=NULL;
Vec3 direction;
float kartDistSquared;
getClosestKart(&closest_kart, &kartDistSquared, &direction,
kart /* search in front of this kart */);
kart /* search in front of this kart */, backwards);
// aim at this kart if 1) it's not too far, 2) if the aimed kart's speed
// allows the projectile to catch up with it
@ -86,6 +87,12 @@ Cake::Cake (Kart *kart) : Flyable(kart, POWERUP_CAKE)
// apply transformation to the bullet object (without pitch)
trans.setRotation(btQuaternion(btVector3(0,1,0), fire_angle));
m_initial_velocity = Vec3(0.0f, up_velocity, m_speed);
createPhysics(forward_offset, m_initial_velocity,
new btCylinderShape(0.5f*m_extend), -m_gravity,
true /* rotation */, false /* backwards */, &trans);
}
else
{
@ -93,13 +100,14 @@ Cake::Cake (Kart *kart) : Flyable(kart, POWERUP_CAKE)
// kart is too far to be hit. so throw the projectile in a generic way,
// straight ahead, without trying to hit anything in particular
trans = kart->getKartHeading(pitch);
m_initial_velocity = Vec3(0.0f, up_velocity, m_speed);
createPhysics(forward_offset, m_initial_velocity,
new btCylinderShape(0.5f*m_extend), -m_gravity,
true /* rotation */, backwards, &trans);
}
m_initial_velocity = Vec3(0.0f, up_velocity, m_speed);
createPhysics(forward_offset, m_initial_velocity,
new btCylinderShape(0.5f*m_extend), -m_gravity,
true /* rotation */, false /* backwards */, &trans);
//do not adjust height according to terrain
setAdjustUpVelocity(false);