Add small feature : in addition to allow resetting a kart when touching something, allow making it 'explode' the kart like when receiving a cake
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@11687 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
@@ -38,8 +38,10 @@
|
||||
ThreeDAnimation::ThreeDAnimation(const XMLNode &node)
|
||||
: AnimationBase(node)
|
||||
{
|
||||
m_crash_reset = false;
|
||||
m_crash_reset = false;
|
||||
m_explode_kart = false;
|
||||
node.get("reset", &m_crash_reset);
|
||||
node.get("explode", &m_explode_kart);
|
||||
|
||||
m_important_animation = (World::getWorld()->getIdent() == IDENT_CUSTSCENE);
|
||||
node.get("important", &m_important_animation);
|
||||
|
||||
@@ -57,6 +57,10 @@ private:
|
||||
* rescuing a kart. */
|
||||
bool m_crash_reset;
|
||||
|
||||
/** True if a collision with this object should trigger
|
||||
* "exploding" a kart. */
|
||||
bool m_explode_kart;
|
||||
|
||||
/** We have to store the rotation value as computed in blender, since
|
||||
* irrlicht uses a different order, so for rotation animations we
|
||||
* can not use the value returned by getRotation from a scene node. */
|
||||
@@ -77,7 +81,7 @@ public:
|
||||
/** Returns true if a collision with this object should
|
||||
* trigger a rescue. */
|
||||
bool isCrashReset() const { return m_crash_reset; }
|
||||
|
||||
bool isExplodeKartObject() const { return m_explode_kart; }
|
||||
}; // ThreeDAnimation
|
||||
#endif
|
||||
|
||||
|
||||
@@ -47,12 +47,14 @@ PhysicalObject::PhysicalObject(const XMLNode &xml_node)
|
||||
m_mass = 1;
|
||||
m_radius = -1;
|
||||
m_crash_reset = false;
|
||||
|
||||
m_explode_kart = false;
|
||||
|
||||
std::string shape;
|
||||
xml_node.get("mass", &m_mass );
|
||||
xml_node.get("radius", &m_radius );
|
||||
xml_node.get("shape", &shape );
|
||||
xml_node.get("reset", &m_crash_reset);
|
||||
xml_node.get("mass", &m_mass );
|
||||
xml_node.get("radius", &m_radius );
|
||||
xml_node.get("shape", &shape );
|
||||
xml_node.get("reset", &m_crash_reset);
|
||||
xml_node.get("explode", &m_explode_kart);
|
||||
|
||||
m_body_type = MP_NONE;
|
||||
if (shape=="cone" ||
|
||||
@@ -101,6 +103,7 @@ PhysicalObject::PhysicalObject(const std::string& model,
|
||||
m_mass = mass;
|
||||
m_radius = radius;
|
||||
m_crash_reset = false;
|
||||
m_explode_kart = false;
|
||||
|
||||
m_init_pos.setIdentity();
|
||||
btQuaternion q;
|
||||
|
||||
@@ -79,6 +79,9 @@ private:
|
||||
|
||||
/** True if a kart colliding with this object should be rescued. */
|
||||
bool m_crash_reset;
|
||||
|
||||
/** True if kart should "explode" when touching this */
|
||||
bool m_explode_kart;
|
||||
|
||||
public:
|
||||
PhysicalObject (const XMLNode &node);
|
||||
@@ -101,6 +104,7 @@ public:
|
||||
/** Returns true if this object should trigger a rescue in a kart that
|
||||
* hits it. */
|
||||
bool isCrashReset() const { return m_crash_reset; }
|
||||
bool isExplodeKartObject () const { return m_explode_kart; }
|
||||
}; // PhysicalObject
|
||||
|
||||
#endif
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "karts/rescue_animation.hpp"
|
||||
#include "network/race_state.hpp"
|
||||
#include "graphics/stars.hpp"
|
||||
#include "karts/explosion_animation.hpp"
|
||||
#include "physics/btKart.hpp"
|
||||
#include "physics/btUprightConstraint.hpp"
|
||||
#include "physics/irr_debug_drawer.hpp"
|
||||
@@ -176,6 +177,11 @@ void Physics::update(float dt)
|
||||
AbstractKart *kart = p->getUserPointer(1)->getPointerKart();
|
||||
new RescueAnimation(kart);
|
||||
}
|
||||
else if (obj->isExplodeKartObject())
|
||||
{
|
||||
AbstractKart *kart = p->getUserPointer(1)->getPointerKart();
|
||||
ExplosionAnimation::create(kart);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -188,6 +194,11 @@ void Physics::update(float dt)
|
||||
AbstractKart *kart = p->getUserPointer(1)->getPointerKart();
|
||||
new RescueAnimation(kart);
|
||||
}
|
||||
else if (anim->isExplodeKartObject())
|
||||
{
|
||||
AbstractKart *kart = p->getUserPointer(1)->getPointerKart();
|
||||
ExplosionAnimation::create(kart);
|
||||
}
|
||||
continue;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user