From e9837ca8fc3c484770bf65e33ac1726782dd5323 Mon Sep 17 00:00:00 2001 From: hikerstk Date: Wed, 7 Jul 2010 23:53:27 +0000 Subject: [PATCH] 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 --- data/stk_config.xml | 4 ++++ src/config/stk_config.cpp | 9 +++++++++ src/config/stk_config.hpp | 4 +++- src/karts/kart.cpp | 8 ++++++++ src/karts/moveable.cpp | 2 +- src/modes/world.cpp | 2 ++ src/modes/world.hpp | 12 +++++++++++- 7 files changed, 38 insertions(+), 3 deletions(-) diff --git a/data/stk_config.xml b/data/stk_config.xml index 5fab5b6f5..101be65f0 100644 --- a/data/stk_config.xml +++ b/data/stk_config.xml @@ -22,6 +22,10 @@ The last values applies for all remaining karts. --> + + + diff --git a/src/config/stk_config.cpp b/src/config/stk_config.cpp index 7681a0d7f..4e3cd1a12 100644 --- a/src/config/stk_config.cpp +++ b/src/config/stk_config.cpp @@ -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; diff --git a/src/config/stk_config.hpp b/src/config/stk_config.hpp index c10fe7152..920d5ef93 100644 --- a/src/config/stk_config.hpp +++ b/src/config/stk_config.hpp @@ -92,6 +92,9 @@ public: std::vector m_leader_intervals; /** + m_startup_boost; /**< The speed boost the fastest players + pressing 'accel' at start get. */ std::vector m_switch_items; /**< How to switch items. */ std::vector m_scores; /**getNumStartedKarts(); + if(m_controls.m_accel>0 && num_startedm_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); diff --git a/src/karts/moveable.cpp b/src/karts/moveable.cpp index 58a84dd3c..742cd9d50 100644 --- a/src/karts/moveable.cpp +++ b/src/karts/moveable.cpp @@ -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 diff --git a/src/modes/world.cpp b/src/modes/world.cpp index b0ec3d077..bf032cc61 100644 --- a/src/modes/world.cpp +++ b/src/modes/world.cpp @@ -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 ) { diff --git a/src/modes/world.hpp b/src/modes/world.hpp index f0b452c4d..86c17de75 100644 --- a/src/modes/world.hpp +++ b/src/modes/world.hpp @@ -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; }