improved plunger to point in right direction and allow shooting backwards
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@2471 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
e74fffd6cc
commit
94cfd1bab8
File diff suppressed because it is too large
Load Diff
@ -65,7 +65,7 @@ Flyable::Flyable(Kart *kart, PowerupType type, float mass) : Moveable()
|
||||
// ----------------------------------------------------------------------------
|
||||
void Flyable::createPhysics(float y_offset, const btVector3 velocity,
|
||||
btCollisionShape *shape, const bool gravity,
|
||||
const bool rotates, const btTransform* customDirection)
|
||||
const bool rotates, const bool turn_around, const btTransform* customDirection)
|
||||
{
|
||||
// Get Kart heading direction
|
||||
btTransform trans = ( customDirection == NULL ? m_owner->getKartHeading() : *customDirection );
|
||||
@ -76,6 +76,16 @@ void Flyable::createPhysics(float y_offset, const btVector3 velocity,
|
||||
btVector3 offset=btVector3(0,y_offset,m_average_height);
|
||||
offset_transform.setOrigin(offset);
|
||||
|
||||
// turn around
|
||||
if(turn_around)
|
||||
{
|
||||
btTransform turn_around_trans;
|
||||
//turn_around_trans.setOrigin(trans.getOrigin());
|
||||
turn_around_trans.setIdentity();
|
||||
turn_around_trans.setRotation(btQuaternion(btVector3(0, 0, 1), M_PI));
|
||||
trans *= turn_around_trans;
|
||||
}
|
||||
|
||||
trans *= offset_transform;
|
||||
|
||||
m_shape = shape;
|
||||
|
@ -74,7 +74,8 @@ protected:
|
||||
void createPhysics(float y_offset,
|
||||
const btVector3 velocity,
|
||||
btCollisionShape *shape, const bool gravity=false,
|
||||
const bool rotates=false, const btTransform* customDirection=NULL);
|
||||
const bool rotates=false, const bool turn_around=false,
|
||||
const btTransform* customDirection=NULL);
|
||||
public:
|
||||
|
||||
Flyable (Kart* kart, PowerupType type, float mass=1.0f);
|
||||
|
@ -19,19 +19,27 @@
|
||||
|
||||
#include "items/plunger.hpp"
|
||||
#include "constants.hpp"
|
||||
#include "coord.hpp"
|
||||
#include "karts/player_kart.hpp"
|
||||
#include "camera.hpp"
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
Plunger::Plunger(Kart *kart) : Flyable(kart, POWERUP_PLUNGER)
|
||||
{
|
||||
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
|
||||
float y_offset = 0.5f*kart->getKartLength()+2.0f*m_extend.getY();
|
||||
|
||||
// if the kart is looking backwards, release from the back
|
||||
PlayerKart* pk = dynamic_cast<PlayerKart*>(kart);
|
||||
const bool reverse_mode = (pk != NULL && pk->getCamera()->getMode() == Camera::CM_REVERSE);
|
||||
|
||||
createPhysics(y_offset, btVector3(0.0f, m_speed*2, 0.0f),
|
||||
new btCylinderShape(0.5f*m_extend), false, false, reverse_mode );
|
||||
} // Plunger
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
void Plunger::init(const lisp::Lisp* lisp, ssgEntity *missile)
|
||||
void Plunger::init(const lisp::Lisp* lisp, ssgEntity *plunger_model)
|
||||
{
|
||||
Flyable::init(lisp, missile, POWERUP_PLUNGER);
|
||||
Flyable::init(lisp, plunger_model, POWERUP_PLUNGER);
|
||||
} // init
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
@ -140,8 +140,6 @@ void PowerupManager::LoadNode(const lisp::Lisp* lisp, int collectType )
|
||||
Bowling::init (lisp, m_all_models[collectType]); break;
|
||||
case POWERUP_PLUNGER:
|
||||
Plunger::init (lisp, m_all_models[collectType]); break;
|
||||
//case POWERUP_BUBBLEGUM:
|
||||
// BubbleGum::init(lisp, m_all_models[collectType]); break;
|
||||
case POWERUP_CAKE:
|
||||
Cake::init (lisp, m_all_models[collectType]); break;
|
||||
default:;
|
||||
|
Loading…
Reference in New Issue
Block a user