Refqactoring: moved static rubber-ball specific settings from Flyable

to RubberBall.


git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@9315 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
hikerstk 2011-07-21 22:07:09 +00:00
parent 4477862356
commit c1d65112e7
4 changed files with 15 additions and 12 deletions

View File

@ -108,7 +108,6 @@ scene::IMesh* Flyable::m_st_model [PowerupManager::POWERUP_MAX];
float Flyable::m_st_min_height [PowerupManager::POWERUP_MAX];
float Flyable::m_st_max_height [PowerupManager::POWERUP_MAX];
float Flyable::m_st_force_updown[PowerupManager::POWERUP_MAX];
float Flyable::m_st_interval [PowerupManager::POWERUP_MAX];
Vec3 Flyable::m_st_extend [PowerupManager::POWERUP_MAX];
// ----------------------------------------------------------------------------
@ -122,7 +121,6 @@ Flyable::Flyable(Kart *kart, PowerupManager::PowerupType type, float mass)
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_interval = m_st_interval[type];
m_owner = kart;
m_type = type;
m_has_hit_something = false;
@ -216,12 +214,10 @@ void Flyable::init(const XMLNode &node, scene::IMesh *model,
m_st_max_height[type] = 1.0f;
m_st_min_height[type] = 3.0f;
m_st_force_updown[type] = 15.0f;
m_st_interval[type] = 1.0f;
node.get("speed", &(m_st_speed[type]) );
node.get("min-height", &(m_st_min_height[type]) );
node.get("max-height", &(m_st_max_height[type]) );
node.get("force-updown", &(m_st_force_updown[type]));
node.get("interval", &(m_st_interval[type]) );
// Store the size of the model
Vec3 min, max;

View File

@ -79,9 +79,6 @@ protected:
/** Force pushing the Flyable up. */
float m_force_updown;
/** Interval (used for rubber ball). */
float m_interval;
/** Speed of this Flyable. */
float m_speed;
@ -111,9 +108,6 @@ protected:
/** Force pushing up/down. */
static float m_st_force_updown[PowerupManager::POWERUP_MAX];
/** Interval, used for the rubber ball. */
static float m_st_interval[PowerupManager::POWERUP_MAX];
/** Size of the model. */
static Vec3 m_st_extend[PowerupManager::POWERUP_MAX];

View File

@ -23,6 +23,8 @@
#include "modes/linear_world.hpp"
#include "tracks/track.hpp"
float RubberBall::m_st_interval;
RubberBall::RubberBall(Kart *kart) : Flyable(kart, PowerupManager::POWERUP_RUBBERBALL,
0.0f /* mass */)
{
@ -70,7 +72,8 @@ RubberBall::RubberBall(Kart *kart) : Flyable(kart, PowerupManager::POWERUP_RUBBE
m_wrapped_around = false;
m_previous_height = 0.0f;
m_timer = 0.0f;
m_height = 0.0f;
m_interval = m_st_interval;
} // RubberBall
// -----------------------------------------------------------------------------
@ -104,6 +107,9 @@ void RubberBall::computeTarget()
*/
void RubberBall::init(const XMLNode &node, scene::IMesh *bowling)
{
m_st_interval = 1.0f;
node.get("interval", &m_st_interval);
Flyable::init(node, bowling, PowerupManager::POWERUP_RUBBERBALL);
} // init

View File

@ -52,8 +52,15 @@ private:
* height newly determined height. */
float m_previous_height;
float m_height;
/** A class variable to store the default interval size. */
static float m_st_interval;
/** How long it takes from one bounce of the ball to the next. */
float m_interval;
/** This timer is used to determine the height depending on the time.
* It is always between 0 and m_interval. */
float m_timer;
/** True if the ball just crossed the start line, i.e. its