Fixed missing stars animation, which is now moved completely into

EmergencyAnimation (see bug 3059588).


git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@5901 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
hikerstk 2010-09-06 11:07:41 +00:00
parent f02c89e835
commit 8b29d20866
4 changed files with 30 additions and 17 deletions

View File

@ -19,6 +19,7 @@
#include "karts/emergency_animation.hpp"
#include "graphics/stars.hpp"
#include "karts/kart.hpp"
#include "modes/world.hpp"
#include "physics/btKart.hpp"
@ -31,21 +32,36 @@
*/
EmergencyAnimation::EmergencyAnimation(Kart *kart)
{
m_kart = kart;
m_stars_effect = NULL;
m_kart = kart;
// Setting kart mode here is important! If the mode should be rescue when
// reset() is called, it is assumed that this was triggered by a restart,
// and that the vehicle must be added back to the physics world. Since
// reset() is also called at the very start, it must be guaranteed that
// rescue is not set.
m_kart_mode = EA_NONE;
m_kart_mode = EA_NONE;
}; // EmergencyAnimation
//-----------------------------------------------------------------------------
EmergencyAnimation::~EmergencyAnimation()
{
if(m_stars_effect)
delete m_stars_effect;
} // ~EmergencyAnimation
//-----------------------------------------------------------------------------
/** Resets all data at the beginning of a race.
*/
void EmergencyAnimation::reset()
{
// Create the stars effect in the first reset
if(!m_stars_effect)
m_stars_effect = new Stars(m_kart->getNode());
// Reset star effect in case that it is currently being shown.
m_stars_effect->reset();
// If the kart was eliminated or rescued, the body was removed from the
// physics world. Add it again.
if(playingEmergencyAnimation())
@ -124,6 +140,7 @@ void EmergencyAnimation::handleExplosion(const Vec3 &pos, bool direct_hit)
m_add_rotation.setHeading( (rand()%(2*max_rotation+1)-max_rotation)*f );
m_add_rotation.setPitch( (rand()%(2*max_rotation+1)-max_rotation)*f );
m_add_rotation.setRoll( (rand()%(2*max_rotation+1)-max_rotation)*f );
m_stars_effect->showFor(6.0f);
} // handleExplosion
@ -134,6 +151,12 @@ void EmergencyAnimation::handleExplosion(const Vec3 &pos, bool direct_hit)
*/
void EmergencyAnimation::update(float dt)
{
if ( UserConfigParams::m_graphical_effects )
{
// update star effect (call will do nothing if stars are not activated)
m_stars_effect->update(dt);
}
if(!playingEmergencyAnimation()) return;
// See if the timer expires, if so return the kart to normal game play

View File

@ -23,6 +23,7 @@
#include "utils/vec3.hpp"
class Kart;
class Stars;
/**
* \brief This class is a 'mixin' for kart, and handles the animated explosion.
@ -63,13 +64,16 @@ private:
/** A pointer to the class to which this object belongs. */
Kart *m_kart;
/** For stars rotating around head effect */
Stars *m_stars_effect;
/** Different kart modes: normal racing, being rescued, showing end
* animation, explosions, kart eliminated. */
enum {EA_NONE, EA_RESCUE, EA_EXPLOSION}
m_kart_mode;
public:
EmergencyAnimation(Kart *kart);
~EmergencyAnimation() {};
~EmergencyAnimation();
void reset();
void handleExplosion(const Vec3& pos, bool direct_hit);
void forceRescue();

View File

@ -34,7 +34,6 @@
#include "graphics/skid_marks.hpp"
#include "graphics/slip_stream.hpp"
#include "graphics/smoke.hpp"
#include "graphics/stars.hpp"
#include "graphics/water_splash.hpp"
#include "modes/world.hpp"
#include "io/file_manager.hpp"
@ -83,7 +82,6 @@ Kart::Kart (const std::string& ident, int position,
m_shadow_enabled = false;
m_shadow = NULL;
m_smoke_system = NULL;
m_stars_effect = NULL;
m_water_splash_system = NULL;
m_nitro = NULL;
m_slip_stream = NULL;
@ -307,7 +305,6 @@ Kart::~Kart()
if(m_slip_stream) delete m_slip_stream;
delete m_shadow;
delete m_stars_effect;
if(m_skidmarks) delete m_skidmarks ;
@ -438,8 +435,6 @@ void Kart::reset()
m_controls.m_drift = false;
m_controls.m_fire = false;
m_controls.m_look_back = false;
// Reset star effect in case that it is currently being shown.
m_stars_effect->reset();
m_slip_stream->reset();
m_vehicle->deactivateZipper();
@ -708,9 +703,6 @@ void Kart::update(float dt)
m_water_splash_system->update(dt);
m_nitro->update(dt);
m_slip_stream->update(dt);
// update star effect (call will do nothing if stars are not activated)
m_stars_effect->update(dt);
} // UserConfigParams::m_graphical_effects
updatePhysics(dt);
@ -1377,8 +1369,6 @@ void Kart::loadData()
m_shadow = new Shadow(m_kart_properties->getShadowTexture(),
m_node);
m_stars_effect = new Stars(m_node);
} // loadData
//-----------------------------------------------------------------------------

View File

@ -47,7 +47,6 @@ class SFXBase;
class SkidMarks;
class SlipStream;
class Smoke;
class Stars;
class WaterSplash;
/** The main kart class. All type of karts are of this object, but with
@ -140,9 +139,6 @@ private:
/** Water splash when driving in water. */
WaterSplash *m_water_splash_system;
/** For stars rotating around head effect */
Stars *m_stars_effect;
/** Graphical effect when using a nitro. */
Nitro *m_nitro;