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:
parent
86715b59c1
commit
e9837ca8fc
@ -22,6 +22,10 @@
|
||||
The last values applies for all remaining karts. -->
|
||||
<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. -->
|
||||
<music title="main_theme.music"/>
|
||||
|
||||
|
@ -82,6 +82,11 @@ void STKConfig::load(const std::string &filename)
|
||||
fprintf(stderr,"No follow leader interval(s) defined in stk_config");
|
||||
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)
|
||||
{
|
||||
fprintf(stderr,"No item switches defined in stk_config");
|
||||
@ -151,6 +156,7 @@ void STKConfig::init_defaults()
|
||||
m_enable_networking = true;
|
||||
m_scores.clear();
|
||||
m_leader_intervals.clear();
|
||||
m_startup_boost.clear();
|
||||
m_switch_items.clear();
|
||||
} // init_defaults
|
||||
|
||||
@ -188,6 +194,9 @@ void STKConfig::getAllData(const XMLNode * root)
|
||||
if(const XMLNode *leader_node= root->getNode("follow-the-leader"))
|
||||
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"))
|
||||
{
|
||||
std::string title_music;
|
||||
|
@ -92,6 +92,9 @@ public:
|
||||
std::vector<float>
|
||||
m_leader_intervals; /**<Interval in follow the leader till
|
||||
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_scores; /**<Scores depending on position. */
|
||||
@ -102,7 +105,6 @@ public:
|
||||
/** Empty constructor. The actual work is done in load. */
|
||||
STKConfig() {};
|
||||
void init_defaults ();
|
||||
// void getAllData (const lisp::Lisp* lisp);
|
||||
void getAllData (const XMLNode * root);
|
||||
void load (const std::string &filename);
|
||||
/** Returns the default kart properties for each kart. */
|
||||
|
@ -1100,6 +1100,14 @@ bool Kart::playCustomSFX(unsigned int type)
|
||||
*/
|
||||
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;
|
||||
float engine_power = getActualWheelForce() + handleNitro(dt)
|
||||
+ handleSlipstream(dt);
|
||||
|
@ -64,10 +64,10 @@ void Moveable::updateGraphics(const Vec3& offset_xyz,
|
||||
const btQuaternion& rotation)
|
||||
{
|
||||
Vec3 xyz=getXYZ()+offset_xyz;
|
||||
m_node->setPosition(xyz.toIrrVector());
|
||||
btQuaternion r_all = getRotation()*rotation;
|
||||
Vec3 hpr;
|
||||
hpr.setHPR(r_all);
|
||||
m_node->setPosition(xyz.toIrrVector());
|
||||
m_node->setRotation(hpr.toIrrHPR());
|
||||
} // updateGraphics
|
||||
|
||||
|
@ -80,6 +80,7 @@ World::World() : WorldStatus(), m_clear_color(255,100,101,140)
|
||||
m_use_highscores = true;
|
||||
m_track = NULL;
|
||||
m_clear_back_buffer = false;
|
||||
m_num_started_karts = 0;
|
||||
|
||||
WorldStatus::setClockMode(CLOCK_CHRONO);
|
||||
} // World
|
||||
@ -633,6 +634,7 @@ void World::restartRace()
|
||||
m_faster_music_active = false;
|
||||
m_eliminated_karts = 0;
|
||||
m_eliminated_players = 0;
|
||||
m_num_started_karts = 0;
|
||||
|
||||
for ( KartList::iterator i = m_karts.begin(); i != m_karts.end() ; ++i )
|
||||
{
|
||||
|
@ -85,6 +85,11 @@ public:
|
||||
private:
|
||||
/** A pointer to the global world object for a race. */
|
||||
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:
|
||||
/** The list of all karts. */
|
||||
KartList m_karts;
|
||||
@ -118,7 +123,6 @@ protected:
|
||||
virtual Kart *createKart(const std::string &kart_ident, int index,
|
||||
int local_player_id, int global_player_id,
|
||||
const btTransform &init_pos);
|
||||
protected:
|
||||
/** Pointer to the track. The track is managed by world. */
|
||||
Track* m_track;
|
||||
|
||||
@ -250,6 +254,12 @@ public:
|
||||
*/
|
||||
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; }
|
||||
|
||||
const irr::video::SColor& getClearColor() const { return m_clear_color; }
|
||||
|
Loading…
Reference in New Issue
Block a user