Added some startup speed boost, mainly for testing. The first two

karts to press 'accelerate' after 'go' will receive a boost. 


git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@5669 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
hikerstk 2010-07-07 23:53:27 +00:00
parent 86715b59c1
commit e9837ca8fc
7 changed files with 38 additions and 3 deletions

View File

@ -22,6 +22,10 @@
The last values applies for all remaining karts. --> The last values applies for all remaining karts. -->
<follow-the-leader intervals="30 20 10"/> <follow-the-leader intervals="30 20 10"/>
<!-- Startup information. Boost: startup speed boost for
the first karts to press acceleration at start -->
<startup boost="10 5" />
<!-- The title music. --> <!-- The title music. -->
<music title="main_theme.music"/> <music title="main_theme.music"/>

View File

@ -82,6 +82,11 @@ void STKConfig::load(const std::string &filename)
fprintf(stderr,"No follow leader interval(s) defined in stk_config"); fprintf(stderr,"No follow leader interval(s) defined in stk_config");
exit(-1); exit(-1);
} }
if(m_startup_boost.size()==0)
{
fprintf(stderr, "No startup speed boost defined in stk_config");
exit(-1);
}
if(m_switch_items.size()!=Item::ITEM_LAST-Item::ITEM_FIRST+1) if(m_switch_items.size()!=Item::ITEM_LAST-Item::ITEM_FIRST+1)
{ {
fprintf(stderr,"No item switches defined in stk_config"); fprintf(stderr,"No item switches defined in stk_config");
@ -151,6 +156,7 @@ void STKConfig::init_defaults()
m_enable_networking = true; m_enable_networking = true;
m_scores.clear(); m_scores.clear();
m_leader_intervals.clear(); m_leader_intervals.clear();
m_startup_boost.clear();
m_switch_items.clear(); m_switch_items.clear();
} // init_defaults } // init_defaults
@ -188,6 +194,9 @@ void STKConfig::getAllData(const XMLNode * root)
if(const XMLNode *leader_node= root->getNode("follow-the-leader")) if(const XMLNode *leader_node= root->getNode("follow-the-leader"))
leader_node->get("intervals", &m_leader_intervals); leader_node->get("intervals", &m_leader_intervals);
if(const XMLNode *startup_boost_node= root->getNode("startup"))
startup_boost_node->get("boost", &m_startup_boost);
if(const XMLNode *music_node = root->getNode("music")) if(const XMLNode *music_node = root->getNode("music"))
{ {
std::string title_music; std::string title_music;

View File

@ -92,6 +92,9 @@ public:
std::vector<float> std::vector<float>
m_leader_intervals; /**<Interval in follow the leader till m_leader_intervals; /**<Interval in follow the leader till
last kart is reomved. */ last kart is reomved. */
std::vector<float>
m_startup_boost; /**< The speed boost the fastest players
pressing 'accel' at start get. */
std::vector<int> m_switch_items; /**< How to switch items. */ std::vector<int> m_switch_items; /**< How to switch items. */
std::vector<int> std::vector<int>
m_scores; /**<Scores depending on position. */ m_scores; /**<Scores depending on position. */
@ -102,7 +105,6 @@ public:
/** Empty constructor. The actual work is done in load. */ /** Empty constructor. The actual work is done in load. */
STKConfig() {}; STKConfig() {};
void init_defaults (); void init_defaults ();
// void getAllData (const lisp::Lisp* lisp);
void getAllData (const XMLNode * root); void getAllData (const XMLNode * root);
void load (const std::string &filename); void load (const std::string &filename);
/** Returns the default kart properties for each kart. */ /** Returns the default kart properties for each kart. */

View File

@ -1100,6 +1100,14 @@ bool Kart::playCustomSFX(unsigned int type)
*/ */
void Kart::updatePhysics(float dt) void Kart::updatePhysics(float dt)
{ {
// Checks for startup speed boost.
unsigned int num_started = World::getWorld()->getNumStartedKarts();
if(m_controls.m_accel>0 && num_started<stk_config->m_startup_boost.size())
{
m_zipper_time_left = 5.0f;
m_vehicle->activateZipper(stk_config->m_startup_boost[num_started]);
World::getWorld()->incNumStartedKarts();
}
m_bounce_back_time-=dt; m_bounce_back_time-=dt;
float engine_power = getActualWheelForce() + handleNitro(dt) float engine_power = getActualWheelForce() + handleNitro(dt)
+ handleSlipstream(dt); + handleSlipstream(dt);

View File

@ -64,10 +64,10 @@ void Moveable::updateGraphics(const Vec3& offset_xyz,
const btQuaternion& rotation) const btQuaternion& rotation)
{ {
Vec3 xyz=getXYZ()+offset_xyz; Vec3 xyz=getXYZ()+offset_xyz;
m_node->setPosition(xyz.toIrrVector());
btQuaternion r_all = getRotation()*rotation; btQuaternion r_all = getRotation()*rotation;
Vec3 hpr; Vec3 hpr;
hpr.setHPR(r_all); hpr.setHPR(r_all);
m_node->setPosition(xyz.toIrrVector());
m_node->setRotation(hpr.toIrrHPR()); m_node->setRotation(hpr.toIrrHPR());
} // updateGraphics } // updateGraphics

View File

@ -80,6 +80,7 @@ World::World() : WorldStatus(), m_clear_color(255,100,101,140)
m_use_highscores = true; m_use_highscores = true;
m_track = NULL; m_track = NULL;
m_clear_back_buffer = false; m_clear_back_buffer = false;
m_num_started_karts = 0;
WorldStatus::setClockMode(CLOCK_CHRONO); WorldStatus::setClockMode(CLOCK_CHRONO);
} // World } // World
@ -633,6 +634,7 @@ void World::restartRace()
m_faster_music_active = false; m_faster_music_active = false;
m_eliminated_karts = 0; m_eliminated_karts = 0;
m_eliminated_players = 0; m_eliminated_players = 0;
m_num_started_karts = 0;
for ( KartList::iterator i = m_karts.begin(); i != m_karts.end() ; ++i ) for ( KartList::iterator i = m_karts.begin(); i != m_karts.end() ; ++i )
{ {

View File

@ -85,6 +85,11 @@ public:
private: private:
/** A pointer to the global world object for a race. */ /** A pointer to the global world object for a race. */
static World *m_world; static World *m_world;
/** Counts the karts that have 'started', i.e. pressed acceleration
* after 'ready-set-go'. The first two karts will get a speed boost. */
unsigned int m_num_started_karts;
protected: protected:
/** The list of all karts. */ /** The list of all karts. */
KartList m_karts; KartList m_karts;
@ -118,7 +123,6 @@ protected:
virtual Kart *createKart(const std::string &kart_ident, int index, virtual Kart *createKart(const std::string &kart_ident, int index,
int local_player_id, int global_player_id, int local_player_id, int global_player_id,
const btTransform &init_pos); const btTransform &init_pos);
protected:
/** Pointer to the track. The track is managed by world. */ /** Pointer to the track. The track is managed by world. */
Track* m_track; Track* m_track;
@ -250,6 +254,12 @@ public:
*/ */
virtual void raceResultOrder( int order[] ) = 0; virtual void raceResultOrder( int order[] ) = 0;
/** Returns the number of started karts, used to determine which karts
* receive a speed boost. */
unsigned int getNumStartedKarts() const { return m_num_started_karts; }
/** Increases the number of karts that have accelerated. */
void incNumStartedKarts() { m_num_started_karts++; }
bool clearBackBuffer() const { return m_clear_back_buffer; } bool clearBackBuffer() const { return m_clear_back_buffer; }
const irr::video::SColor& getClearColor() const { return m_clear_color; } const irr::video::SColor& getClearColor() const { return m_clear_color; }