1) Increased top speed and effect of wheelies.

2) Added support for 'nitro' mode: no wheelies, instead
   collected energy can be used for a speed boost.


git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@2499 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
hikerstk 2008-11-24 23:19:47 +00:00
parent 409d828389
commit 2893292816
11 changed files with 76 additions and 46 deletions

View File

@ -11,6 +11,7 @@
;; 1st
(title-music "main_theme.music")
(menu-background "st_title_screen.rgb")
(game-style "wheelie") ;; "wheelie" or "nitro"
(max-history 10000) ;; maximum number of history frames.
(delay-finish-time 10) ;; delay till race results are displayed.
(music-credit-time 10) ;; time for which the music credits are displayed.
@ -45,7 +46,6 @@
(time-full-steer 0.3 )
(corn-f 4 )
(corn-r 4 )
(wheelie-max-speed-ratio 0.7 ) ;; percentage of max speed for wheelies to work
;; Shift of the chassis with regards to the center of mass. E.g. with the
;; the value commented out below the chassis will be 30 cm higher than the
@ -55,6 +55,8 @@
;; Default (if nothing is defined here) is that the center of the mass is
;; at the very bottom of the chassis!
;;(gravity-center-shift 0 0 0.3)
(wheelie-max-speed-ratio 0.5 ) ;; percentage of max speed for wheelies to work
(wheelie-max-pitch 45.0 ) ;; maximum pitch to use when doing a wheelie
(wheelie-pitch-rate 60.0 ) ;; rate/sec with which the kart goes up
(wheelie-restore-rate 90.0 ) ;; rate/sec with which the kart does down
@ -62,7 +64,7 @@
(wheelie-lean-recovery 1 )
(wheelie-balance-recovery 2 )
(wheelie-step 1 )
(wheelie-power-boost 1 ) ;; increase in engine power, i.e. 1=plus 100%
(wheelie-power-boost 3 ) ;; increase in engine power, i.e. 1=plus 100%
;; Bullet physics attributes
(brake-factor 2.75 )
@ -86,8 +88,8 @@
(wheel-radius 0.25 )
(wheel-width 0.3 )
(chassis-linear-damping 0.2 )
(chassis-angular-damping 0.2 )
(maximum-speed 22.22 ) ;; = 80 km/h
(chassis-angular-damping 30.2 )
(maximum-speed 32.22 ) ;; = 80 km/h
(max-speed-reverse-ratio 0.2 ) ;; percentage of max speed for reverse gear
(suspension-rest 0.2 )
(suspension-travel-cm 19 )

View File

@ -224,7 +224,7 @@ bool ChallengeData::raceFinished()
if((int)race_manager->getNumKarts()<m_num_karts) return false; // not enough AI karts
Kart* kart = RaceManager::getPlayerKart(0);
if(m_energy>0 && kart->getNumItems()<m_energy) return false; // not enough energy
if(m_energy>0 && kart->getEnergy() <m_energy ) return false; // not enough energy
if(m_position>0 && kart->getPosition()>m_position) return false; // too far behind
// Follow the leader

View File

@ -463,7 +463,7 @@ void RaceGUI::drawPowerupIcons ( Kart* player_kart, int offset_x,
void RaceGUI::drawEnergyMeter ( Kart *player_kart, int offset_x, int offset_y,
float ratio_x, float ratio_y )
{
float state = (float)(player_kart->getNumItems()) /
float state = (float)(player_kart->getEnergy()) /
MAX_ITEMS_COLLECTED;
int x = (int)((user_config->m_width-24) * ratio_x) + offset_x;
int y = (int)(250 * ratio_y) + offset_y;
@ -699,7 +699,8 @@ void RaceGUI::drawSpeed(Kart* kart, int offset_x, int offset_y,
offset_y+(int)(10*minRatio));
else
{
if ( speed >= kart->getMaxSpeed()*kart->getWheelieMaxSpeedRatio() )
if (stk_config->m_game_style==STKConfig::GS_WHEELIE &&
speed >= kart->getMaxSpeed()*kart->getWheelieMaxSpeedRatio() )
{
font_race->PrintShadow("l", (int)(60*minRatio),
offset_x+(int)(70*minRatio), offset_y);

View File

@ -176,9 +176,9 @@ void RaceOptions::select()
switch ( widget_manager->getSelectedWgt() )
{
case WTOK_DIFFICULTY_UP:
if( m_difficulty == RaceManager::RD_HARD && !unlock_manager->isLocked("skidding"))
if( m_difficulty == RaceManager::RD_HARD )
{
m_difficulty = RaceManager::RD_SKIDDING;
m_difficulty = RaceManager::RD_EASY;
}
else if( m_difficulty == RaceManager::RD_MEDIUM )
{
@ -198,12 +198,7 @@ void RaceOptions::select()
break;
case WTOK_DIFFICULTY_DOWN:
if( m_difficulty == RaceManager::RD_SKIDDING )
{
m_difficulty = RaceManager::RD_HARD;
}
else if( m_difficulty == RaceManager::RD_HARD )
if( m_difficulty == RaceManager::RD_HARD )
{
//TEMP: done just for the release after 0.4 because of AI problems
#if ENABLE_MEDIUM_AI
@ -270,7 +265,7 @@ void RaceOptions::select()
case WTOK_START:
if( m_difficulty >= RaceManager::RD_EASY &&
m_difficulty <= RaceManager::RD_SKIDDING)
m_difficulty <= RaceManager::RD_HARD)
{
race_manager->setDifficulty((RaceManager::Difficulty)m_difficulty);
}
@ -310,7 +305,6 @@ const char *RaceOptions::getDifficultyString(int difficulty) const
case RaceManager::RD_EASY: return _("Novice");
case RaceManager::RD_MEDIUM: return _("Driver");
case RaceManager::RD_HARD: return _("Racer" );
case RaceManager::RD_SKIDDING: return _("Skidding Preview");
default: return _("Novice");
} // switch

View File

@ -72,7 +72,7 @@ Kart::Kart (const std::string& kart_name, int position,
m_kart_properties = kart_properties_manager->getKart(kart_name);
//m_grid_position = position;
m_initial_position = position;
m_num_items_collected = 0;
m_collected_energy = 0;
m_eliminated = false;
m_finished_race = false;
m_finish_time = 0.0f;
@ -314,7 +314,7 @@ void Kart::reset()
m_eliminated = false;
m_finish_time = 0.0f;
m_zipper_time_left = 0.0f;
m_num_items_collected = 0;
m_collected_energy = 0;
m_wheel_rotation = 0;
m_wheelie_angle = 0.0f;
m_bounce_back_time = 0.0f;
@ -366,13 +366,19 @@ void Kart::collectedItem(const Item &item, int add_info)
switch (type)
{
case ITEM_BANANA : m_attachment.hitBanana(item, add_info); break;
case ITEM_SILVER_COIN : m_num_items_collected++ ; break;
case ITEM_GOLD_COIN : m_num_items_collected += 3 ; break;
case ITEM_BONUS_BOX : {
int n=1 + 4*getNumItems() / MAX_ITEMS_COLLECTED;
m_powerup.hitBonusBox(n, item,add_info); break;
}
case ITEM_BANANA : m_attachment.hitBanana(item, add_info); break;
case ITEM_SILVER_COIN : m_collected_energy++ ; break;
case ITEM_GOLD_COIN : m_collected_energy += 3 ; break;
case ITEM_BONUS_BOX :
{
// In wheelie style, karts get more items depending on energy,
// in nitro mode it's only one item.
int n = (int)(stk_config->m_game_style==STKConfig::GS_WHEELIE
? 1 + 4*getEnergy() / MAX_ITEMS_COLLECTED
: 1);
m_powerup.hitBonusBox(n, item,add_info);
break;
}
case ITEM_BUBBLEGUM:
// slow down
m_body->setLinearVelocity(m_body->getLinearVelocity()*0.3f);
@ -390,8 +396,8 @@ void Kart::collectedItem(const Item &item, int add_info)
race_state->itemCollected(getWorldKartId(), item.getItemId());
}
if ( m_num_items_collected > MAX_ITEMS_COLLECTED )
m_num_items_collected = MAX_ITEMS_COLLECTED;
if ( m_collected_energy > MAX_ITEMS_COLLECTED )
m_collected_energy = MAX_ITEMS_COLLECTED;
} // collectedItem
@ -574,7 +580,8 @@ void Kart::update(float dt)
} // update
//-----------------------------------------------------------------------------
// Set zipper time, and apply one time additional speed boost
/** Sets zipper time, and apply one time additional speed boost.
*/
void Kart::handleZipper()
{
// Ignore a zipper that's activated while braking
@ -616,10 +623,23 @@ void Kart::draw()
// -----------------------------------------------------------------------------
/** Returned an additional engine power boost when doing a wheele.
***/
* \param dt Time step size.
*/
float Kart::handleWheelie(float dt)
{
// For now: handle nitro mode here:
if(stk_config->m_game_style==STKConfig::GS_NITRO)
{
if(!m_controls.wheelie) return 0.0;
m_collected_energy -= dt;
if(m_collected_energy<0)
{
m_collected_energy = 0;
return 0.0;
}
return m_kart_properties->getWheeliePowerBoost() * getMaxPower();
}
// Handle wheelies
// ===============
if ( m_controls.wheelie &&
@ -645,14 +665,6 @@ float Kart::handleWheelie(float dt)
return 0.0f;
}
const btTransform& chassisTrans = getTrans();
btVector3 targetUp(0.0f, 0.0f, 1.0f);
btVector3 forwardW (chassisTrans.getBasis()[0][1],
chassisTrans.getBasis()[1][1],
chassisTrans.getBasis()[2][1]);
btVector3 crossProd = targetUp.cross(forwardW);
crossProd.normalize();
return m_kart_properties->getWheeliePowerBoost() * getMaxPower()
* m_wheelie_angle/getWheelieMaxPitch();
} // handleWheelie

View File

@ -69,7 +69,8 @@ protected:
btUprightConstraint *m_uprightConstraint;
private:
int m_num_items_collected;
/** The amount of energy collected bu hitting coins. */
float m_collected_energy;
ssgSimpleState* m_smokepuff;
// don't delete the following 2 vars (they're kids in the hirarchy)
Smoke *m_smoke_system;
@ -131,7 +132,7 @@ public:
{ m_attachment.set(t, time_left, k); }
Powerup *getPowerup () { return &m_powerup; }
int getNumPowerup () const { return m_powerup.getNum();}
int getNumItems () const { return m_num_items_collected;}
float getEnergy () const { return m_collected_energy;}
int getPosition () const { return m_race_position; }
int getInitialPosition () const { return m_initial_position; }
float getFinishTime () const { return m_finish_time; }

View File

@ -291,11 +291,11 @@ void PlayerKart::handleZipper()
void PlayerKart::collectedItem(const Item &item, int add_info)
{
// FIXME - how does the old item relate to the total amount of items?
const int old_item_collected = getNumItems();
const float old_energy= getEnergy();
Kart::collectedItem(item, add_info);
if(old_item_collected < MAX_ITEMS_COLLECTED &&
getNumItems() == MAX_ITEMS_COLLECTED)
if(old_energy < MAX_ITEMS_COLLECTED &&
getEnergy() == MAX_ITEMS_COLLECTED)
{
m_full_sound->play();
}

View File

@ -89,8 +89,8 @@ public:
#undef LINEAR_RACE
#undef BATTLE_ARENA
/** Difficulty. Atm skidding is implemented as a special difficulty. */
enum Difficulty { RD_EASY, RD_MEDIUM, RD_HARD, RD_SKIDDING };
/** Difficulty. */
enum Difficulty { RD_EASY, RD_MEDIUM, RD_HARD };
/** Different kart types: A local player, a player connected via network,
* an AI kart, the leader kart (currently not used), a ghost kart

View File

@ -73,7 +73,6 @@ DefaultRobot::DefaultRobot(const std::string& kart_name,
m_min_steps = 1;
break;
case RaceManager::RD_HARD:
case RaceManager::RD_SKIDDING:
m_wait_for_players = false;
m_max_handicap_accel = 1.0f;
m_fallback_tactic = FT_FAREST_POINT;

View File

@ -132,6 +132,7 @@ void STKConfig::init_defaults()
m_grid_order = -100;
m_max_history = -100;
m_title_music = NULL;
m_game_style = GS_WHEELIE;
m_scores.clear();
m_leader_intervals.clear();
} // init_defaults
@ -171,6 +172,19 @@ void STKConfig::getAllData(const lisp::Lisp* lisp)
std::string title_music;
lisp->get("title-music", title_music );
m_title_music = new MusicInformation(file_manager->getMusicFile(title_music));
std::string style;
if(lisp->get("game-style", style))
{
if(style=="wheelie")
m_game_style = GS_WHEELIE;
else if(style=="nitro")
m_game_style = GS_NITRO;
else
{
fprintf(stderr, "Invalid value of game style: '%s'\n", style.c_str());
exit(-1);
}
} // if game-style
// Get the default KartProperties
// ------------------------------

View File

@ -67,6 +67,13 @@ public:
or reverse point order. */
int m_max_history; /**<Maximum number of frames to save in
a history files. */
/** Gaming style: in wheelie, karts can do wheelies, collected coins
* increase the number of items you get. With nitro, collected coins
* can be used as a speed boost (nitro), but no wheelies are possible.
*/
enum GameStyle {GS_WHEELIE, GS_NITRO};
GameStyle m_game_style; /**< Gamestyle: wheelies or nitro */
std::vector<float>
m_leader_intervals; /**<Interval in follow the leader till