1) Improved handling of rockets
2) Enabled timing display again 3) Some code cleanup. git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@1382 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
7e844312c7
commit
57df099065
@ -7,9 +7,9 @@
|
||||
(speed 35.0)
|
||||
(min-height 0.2)
|
||||
(max-height 1.0)
|
||||
(force-updown 25.0) ;; force raising/lowering the homing missile if it's too low/high
|
||||
(max-distance 20.0) ;; maximum distance at which a kart is still followed
|
||||
(max-turn-angle 5.0) ;; maximum turn angle when following a kart
|
||||
(force-updown 25.0) ;; force raising/lowering the homing missile if it's too low/high
|
||||
)
|
||||
|
||||
;; EOF ;;
|
||||
|
@ -5,9 +5,9 @@
|
||||
(model "missile.ac")
|
||||
(icon "missile.rgb")
|
||||
(speed 50.0)
|
||||
(min-height 0.2)
|
||||
(min-height 0.3)
|
||||
(max-height 1.0)
|
||||
(force-updown 15.0)
|
||||
(force-updown 20)
|
||||
)
|
||||
|
||||
;; EOF ;;
|
||||
|
@ -7,9 +7,9 @@
|
||||
(speed 5.0)
|
||||
(min-height 0.2) ; height above terrain below which a spark is
|
||||
; started to be pulled up
|
||||
(max-height 3.0) ; height above terrain at which a spark is
|
||||
(max-height 1.0) ; height above terrain at which a spark is
|
||||
; started to be pulled back to ground
|
||||
(force-updown 20.0) ; force pushing the spark down
|
||||
(force-updown 2.0) ; force pushing the spark down
|
||||
; when it's too high above ground
|
||||
(force-to-target 20) ; force with which a spark flies towards
|
||||
; the nearest kart
|
||||
|
@ -43,6 +43,7 @@ Flyable::Flyable(Kart *kart, CollectableType type) : Moveable(false)
|
||||
m_extend = m_st_extend[type];
|
||||
m_max_height = m_st_max_height[type];
|
||||
m_min_height = m_st_min_height[type];
|
||||
m_average_height = (m_min_height+m_max_height)/2.0f;
|
||||
m_force_updown = m_st_force_updown[type];
|
||||
|
||||
m_owner = kart;
|
||||
@ -59,7 +60,7 @@ Flyable::Flyable(Kart *kart, CollectableType type) : Moveable(false)
|
||||
scene->add(m);
|
||||
} // Flyable
|
||||
// ----------------------------------------------------------------------------
|
||||
void Flyable::createPhysics(const btVector3& offset, const btVector3 velocity,
|
||||
void Flyable::createPhysics(float y_offset, const btVector3 velocity,
|
||||
btCollisionShape *shape)
|
||||
{
|
||||
// The actual transform is determined as follows:
|
||||
@ -85,6 +86,7 @@ void Flyable::createPhysics(const btVector3& offset, const btVector3 velocity,
|
||||
// Apply rotation and offset
|
||||
btTransform offset_transform;
|
||||
offset_transform.setIdentity();
|
||||
btVector3 offset=btVector3(0,y_offset,m_average_height);
|
||||
offset_transform.setOrigin(offset);
|
||||
|
||||
trans *= offset_transform;
|
||||
@ -179,15 +181,18 @@ void Flyable::update (float dt)
|
||||
}
|
||||
|
||||
float hat = trans.getOrigin().getZ()-getHoT();
|
||||
if(hat<m_min_height)
|
||||
too_low(dt);
|
||||
else if(hat>m_max_height)
|
||||
too_high(dt);
|
||||
else
|
||||
right_height(dt);
|
||||
|
||||
// Use the Height Above Terrain to set the Z velocity.
|
||||
// HAT is clamped by min/max height. This might be somewhat
|
||||
// unphysical, but feels right in the game.
|
||||
hat = std::max(std::min(hat, m_max_height) , m_min_height);
|
||||
float delta = m_average_height - hat;
|
||||
btVector3 v=getVelocity();
|
||||
v.setZ(m_force_updown*delta);
|
||||
setVelocity(v);
|
||||
|
||||
Moveable::update(dt);
|
||||
} // update
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
void Flyable::placeModel()
|
||||
{
|
||||
|
@ -36,6 +36,7 @@ protected:
|
||||
btCollisionShape *m_shape;
|
||||
float m_max_height;
|
||||
float m_min_height;
|
||||
float m_average_height; // average of m_{min,ax}_height
|
||||
float m_force_updown;
|
||||
float m_speed;
|
||||
float m_mass;
|
||||
@ -53,17 +54,7 @@ protected:
|
||||
|
||||
void getClosestKart(const Kart **minKart, float *minDist,
|
||||
btVector3 *minDelta) const;
|
||||
virtual void too_low (float dt)
|
||||
{m_body->applyCentralForce(
|
||||
btVector3(0.0f, 0.0f, m_force_updown)); }
|
||||
virtual void too_high(float dt)
|
||||
{m_body->applyCentralForce(
|
||||
btVector3(0.0f, 0.0f, -m_force_updown)); }
|
||||
virtual void right_height(float dt)
|
||||
{btVector3 v=m_body->getLinearVelocity();
|
||||
v.setZ(0.0f);
|
||||
m_body->setLinearVelocity(v); }
|
||||
void createPhysics(const btVector3& offset,
|
||||
void createPhysics(float y_offset,
|
||||
const btVector3 velocity,
|
||||
btCollisionShape *shape);
|
||||
public:
|
||||
|
@ -243,7 +243,6 @@ void RaceGUI::drawFPS ()
|
||||
//-----------------------------------------------------------------------------
|
||||
void RaceGUI::drawTimer ()
|
||||
{
|
||||
return;
|
||||
if(world->getPhase()!=World::RACE_PHASE &&
|
||||
world->getPhase()!=World::DELAY_FINISH_PHASE ) return;
|
||||
char str[256];
|
||||
|
@ -24,16 +24,20 @@ float Homing::m_st_max_distance;
|
||||
float Homing::m_st_max_turn_angle;
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
/** A homing missile is handled as a kinematic object, since this simplifies
|
||||
* computation of turning (otherwise rotational forces would have to be
|
||||
* applied). As a result, the mass must be zero, and linear velocity of the
|
||||
* body can not be set (asserts in bullet). So this object implements its
|
||||
* own setting/getting of velocity, to be able to use flyables functions.
|
||||
*/
|
||||
Homing::Homing (Kart *kart) : Flyable(kart, COLLECT_HOMING)
|
||||
{
|
||||
m_mass = 0.0f; // a kinematik object must have mass=0, otherwise warnings
|
||||
// will be printed during bullet collision handling.
|
||||
btVector3 offset(0.0f,
|
||||
kart->getKartLength()+2.0f*m_extend.getY(),
|
||||
0.3f );
|
||||
// The cylinder needs to be rotated by 90 degrees to face in the right direction:
|
||||
float y_offset=kart->getKartLength()+2.0f*m_extend.getY();
|
||||
|
||||
m_initial_velocity = btVector3(0.0f, m_speed, 0.0f);
|
||||
createPhysics(offset, m_initial_velocity, new btCylinderShape(0.5f*m_extend));
|
||||
createPhysics(y_offset, m_initial_velocity, new btCylinderShape(0.5f*m_extend));
|
||||
m_body->setCollisionFlags(m_body->getCollisionFlags() |
|
||||
btCollisionObject::CF_KINEMATIC_OBJECT );
|
||||
m_body->setActivationState(DISABLE_DEACTIVATION);
|
||||
|
@ -30,16 +30,15 @@ private:
|
||||
btVector3 m_initial_velocity;
|
||||
float steerTowards(btTransform& trans, btVector3& target);
|
||||
|
||||
protected:
|
||||
virtual void too_low (float dt) {m_initial_velocity.setZ(m_force_updown*dt);}
|
||||
virtual void too_high(float dt) {m_initial_velocity.setZ(-m_force_updown*dt);}
|
||||
virtual void right_height(float dt) {m_initial_velocity.setZ(0.0f); }
|
||||
|
||||
public:
|
||||
Homing (Kart *kart);
|
||||
static void init (const lisp::Lisp* lisp, ssgEntity* homing);
|
||||
virtual void update (float dt);
|
||||
virtual void hitTrack () { explode(NULL); }
|
||||
// Kinematic objects are not allowed to have a velocity (assertion in
|
||||
// bullet), so we have to do our own velocity handling here
|
||||
virtual const btVector3 &getVelocity() const {return m_initial_velocity;}
|
||||
virtual void setVelocity(const btVector3& v) {m_initial_velocity=v; }
|
||||
|
||||
}; // Homing
|
||||
|
||||
|
@ -23,10 +23,8 @@
|
||||
// -----------------------------------------------------------------------------
|
||||
Missile::Missile(Kart *kart) : Flyable(kart, COLLECT_MISSILE)
|
||||
{
|
||||
btVector3 offset(0.0f,
|
||||
kart->getKartLength()+2.0f*m_extend.getY(),
|
||||
0.3f );
|
||||
createPhysics(offset, btVector3(0.0f, m_speed, 0.0f),
|
||||
float y_offset=kart->getKartLength()+2.0f*m_extend.getY();
|
||||
createPhysics(y_offset, btVector3(0.0f, m_speed, 0.0f),
|
||||
new btCylinderShape(0.5f*m_extend));
|
||||
} // Missile
|
||||
|
||||
|
@ -65,8 +65,9 @@ public:
|
||||
virtual ~Moveable();
|
||||
|
||||
ssgTransform* getModelTransform() {return m_model_transform; }
|
||||
const btVector3 &getVelocity() const {return m_body->getLinearVelocity();}
|
||||
virtual const btVector3 &getVelocity() const {return m_body->getLinearVelocity();}
|
||||
const btVector3 &getVelocityLC() const {return m_velocityLC; }
|
||||
virtual void setVelocity(const btVector3& v) {m_body->setLinearVelocity(v); }
|
||||
sgCoord* getCoord () {return &m_curr_pos; }
|
||||
const sgCoord* getCoord () const {return &m_curr_pos; }
|
||||
const sgVec4* getNormalHOT () const {return m_normal_hot; }
|
||||
|
@ -24,18 +24,16 @@ float Spark::m_st_force_to_target;
|
||||
// -----------------------------------------------------------------------------
|
||||
Spark::Spark(Kart *kart) : Flyable(kart, COLLECT_SPARK)
|
||||
{
|
||||
btVector3 offset(0.0f,
|
||||
-0.5f*kart->getKartLength()-2.0f*m_extend.getY(),
|
||||
0.5f*kart->getKartHeight());
|
||||
float y_offset = -0.5f*kart->getKartLength()-2.0f*m_extend.getY();
|
||||
float speed = -m_speed;
|
||||
// if the kart is driving backwards, release from the front
|
||||
if(m_owner->getSpeed()<0)
|
||||
{
|
||||
offset.setY(0.5f*kart->getKartLength()+2.0f*m_extend.getY());
|
||||
speed = m_speed;
|
||||
y_offset = -y_offset;
|
||||
speed = -speed;
|
||||
}
|
||||
|
||||
createPhysics(offset, btVector3(0.0f, speed, 0.0f),
|
||||
createPhysics(y_offset, btVector3(0.0f, speed, 0.0f),
|
||||
new btSphereShape(0.5f*m_extend.getY()));
|
||||
|
||||
// unset no_contact_response flags, so that the spark
|
||||
|
@ -17,13 +17,6 @@
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
//#define DEBUG_SHOW_DRIVEPOINTS //This would place a small sphere in every point
|
||||
//of the driveline, the one at the first point
|
||||
//is purple, the others are yellow.
|
||||
#ifdef DEBUG_SHOW_DRIVEPOINTS
|
||||
#include <plib/ssgAux.h>
|
||||
#endif
|
||||
|
||||
#include <assert.h>
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
|
Loading…
Reference in New Issue
Block a user