From: <au...@us...> - 2008-10-30 02:03:01
|
Revision: 2400 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=2400&view=rev Author: auria Date: 2008-10-30 02:02:56 +0000 (Thu, 30 Oct 2008) Log Message: ----------- renamed 'collectible' to 'powerup' Modified Paths: -------------- trunk/supertuxkart/src/Makefile.am trunk/supertuxkart/src/flyable.cpp trunk/supertuxkart/src/flyable.hpp trunk/supertuxkart/src/gui/help_page_one.cpp trunk/supertuxkart/src/gui/help_page_two.cpp trunk/supertuxkart/src/gui/race_gui.cpp trunk/supertuxkart/src/gui/race_gui.hpp trunk/supertuxkart/src/ide/Xcode/STK_XCode.xcodeproj/project.pbxproj trunk/supertuxkart/src/items/bowling.cpp trunk/supertuxkart/src/items/cake.cpp trunk/supertuxkart/src/items/missile.cpp trunk/supertuxkart/src/items/projectile_manager.cpp trunk/supertuxkart/src/items/projectile_manager.hpp trunk/supertuxkart/src/kart.cpp trunk/supertuxkart/src/kart.hpp trunk/supertuxkart/src/main.cpp trunk/supertuxkart/src/modes/standard_race.cpp trunk/supertuxkart/src/modes/world.cpp trunk/supertuxkart/src/network/race_state.cpp trunk/supertuxkart/src/player_kart.cpp trunk/supertuxkart/src/robots/default_robot.cpp trunk/supertuxkart/src/sdldrv.cpp Added Paths: ----------- trunk/supertuxkart/src/items/powerup.cpp trunk/supertuxkart/src/items/powerup.hpp trunk/supertuxkart/src/items/powerup_manager.cpp trunk/supertuxkart/src/items/powerup_manager.hpp Removed Paths: ------------- trunk/supertuxkart/src/items/collectable.cpp trunk/supertuxkart/src/items/collectable.hpp trunk/supertuxkart/src/items/collectable_manager.cpp trunk/supertuxkart/src/items/collectable_manager.hpp Modified: trunk/supertuxkart/src/Makefile.am =================================================================== --- trunk/supertuxkart/src/Makefile.am 2008-10-30 01:53:41 UTC (rev 2399) +++ trunk/supertuxkart/src/Makefile.am 2008-10-30 02:02:56 UTC (rev 2400) @@ -58,8 +58,8 @@ grand_prix_manager.cpp grand_prix_manager.hpp \ items/attachment.cpp items/attachment.hpp \ items/attachment_manager.cpp items/attachment_manager.hpp \ - items/collectable.cpp items/collectable.hpp \ - items/collectable_manager.cpp items/collectable_manager.hpp \ + items/powerup.cpp items/powerup.hpp \ + items/powerup_manager.cpp items/powerup_manager.hpp \ items/item.cpp items/item.hpp \ items/item_manager.cpp items/item_manager.hpp \ items/projectile_manager.cpp items/projectile_manager.hpp \ Modified: trunk/supertuxkart/src/flyable.cpp =================================================================== --- trunk/supertuxkart/src/flyable.cpp 2008-10-30 01:53:41 UTC (rev 2399) +++ trunk/supertuxkart/src/flyable.cpp 2008-10-30 02:02:56 UTC (rev 2400) @@ -31,15 +31,15 @@ #include "modes/linear_world.hpp" // static variables: -float Flyable::m_st_speed[COLLECT_MAX]; -ssgEntity* Flyable::m_st_model[COLLECT_MAX]; -float Flyable::m_st_min_height[COLLECT_MAX]; -float Flyable::m_st_max_height[COLLECT_MAX]; -float Flyable::m_st_force_updown[COLLECT_MAX]; -btVector3 Flyable::m_st_extend[COLLECT_MAX]; +float Flyable::m_st_speed[POWERUP_MAX]; +ssgEntity* Flyable::m_st_model[POWERUP_MAX]; +float Flyable::m_st_min_height[POWERUP_MAX]; +float Flyable::m_st_max_height[POWERUP_MAX]; +float Flyable::m_st_force_updown[POWERUP_MAX]; +btVector3 Flyable::m_st_extend[POWERUP_MAX]; // ---------------------------------------------------------------------------- -Flyable::Flyable(Kart *kart, CollectableType type, float mass) : Moveable() +Flyable::Flyable(Kart *kart, PowerupType type, float mass) : Moveable() { // get the appropriate data from the static fields m_speed = m_st_speed[type]; @@ -99,7 +99,7 @@ // ----------------------------------------------------------------------------- void Flyable::init(const lisp::Lisp* lisp, ssgEntity *model, - CollectableType type) + PowerupType type) { m_st_speed[type] = 25.0f; m_st_max_height[type] = 1.0f; Modified: trunk/supertuxkart/src/flyable.hpp =================================================================== --- trunk/supertuxkart/src/flyable.hpp 2008-10-30 01:53:41 UTC (rev 2399) +++ trunk/supertuxkart/src/flyable.hpp 2008-10-30 02:02:56 UTC (rev 2400) @@ -55,12 +55,12 @@ // speed, min_height, max_height. These variables must be static, // so we need arrays of these variables to have different values // for bowling balls, missiles, ... - static float m_st_speed[COLLECT_MAX]; // Speed of the projectile - static ssgEntity* m_st_model[COLLECT_MAX]; // 3d model - static float m_st_min_height[COLLECT_MAX]; // min height above track - static float m_st_max_height[COLLECT_MAX]; // max height above track - static float m_st_force_updown[COLLECT_MAX]; // force pushing up/down - static btVector3 m_st_extend[COLLECT_MAX]; // size of the model + static float m_st_speed[POWERUP_MAX]; // Speed of the projectile + static ssgEntity* m_st_model[POWERUP_MAX]; // 3d model + static float m_st_min_height[POWERUP_MAX]; // min height above track + static float m_st_max_height[POWERUP_MAX]; // max height above track + static float m_st_force_updown[POWERUP_MAX]; // force pushing up/down + static btVector3 m_st_extend[POWERUP_MAX]; // size of the model /** Returns information on what is the closest kart and at what distance it is. All 3 parameters first are of type 'out'. @@ -76,14 +76,14 @@ const bool rotates=false, const btTransform* customDirection=NULL); public: - Flyable (Kart* kart, CollectableType type, float mass=1.0f); + Flyable (Kart* kart, PowerupType type, float mass=1.0f); virtual ~Flyable (); /** Enables/disables adjusting ov velocity depending on height above * terrain. Missiles can 'follow the terrain' with this adjustment, * but gravity will basically be disabled. */ void setAdjustZVelocity(bool f) { m_adjust_z_velocity = f; } static void init (const lisp::Lisp* lisp, ssgEntity *model, - CollectableType type); + PowerupType type); virtual void update (float); void updateFromServer(const FlyableInfo &f, float dt); Modified: trunk/supertuxkart/src/gui/help_page_one.cpp =================================================================== --- trunk/supertuxkart/src/gui/help_page_one.cpp 2008-10-30 01:53:41 UTC (rev 2399) +++ trunk/supertuxkart/src/gui/help_page_one.cpp 2008-10-30 02:02:56 UTC (rev 2400) @@ -118,9 +118,9 @@ widget_manager->breakLine(); widget_manager->addTextWgt(WTOK_MSG6, 100, 17, -_("Collecting coins increases the number of collectables you receive.\n\ -After 5 silver coins, each blue box will yield 2 collectables,\nafter 10,\ - 3 collectables and so on.\nEach gold coin is worth 3 silver coins, \ +_("Collecting coins increases the number of powerups you receive.\n\ +After 5 silver coins, each blue box will yield 2 powerups,\nafter 10,\ + 3 powerups and so on.\nEach gold coin is worth 3 silver coins, \ so look out for them!")); widget_manager->setWgtResizeToText( WTOK_MSG6, false); widget_manager->breakLine(); Modified: trunk/supertuxkart/src/gui/help_page_two.cpp =================================================================== --- trunk/supertuxkart/src/gui/help_page_two.cpp 2008-10-30 01:53:41 UTC (rev 2399) +++ trunk/supertuxkart/src/gui/help_page_two.cpp 2008-10-30 02:02:56 UTC (rev 2400) @@ -20,6 +20,7 @@ #include "help_page_two.hpp" #include "widget_manager.hpp" #include "menu_manager.hpp" + #include "translation.hpp" enum WidgetTokens @@ -53,11 +54,11 @@ ); widget_manager->addTextWgt( WTOK_MSG, 100, 7, - _("To help you win, there are certain collectables you can grab:")); + _("To help you win, there are certain powerups you can grab:")); widget_manager->breakLine(); widget_manager->addImgWgt( WTOK_IMG1, 10, 12, - collectable_manager->getIcon(COLLECT_MISSILE)->getState()->getTextureHandle()); + powerup_manager->getIcon(POWERUP_MISSILE)->getState()->getTextureHandle()); widget_manager->addTextWgt( WTOK_TXT1, 90, 12, _("Missile - fast stopper in a straight line")); @@ -65,7 +66,7 @@ widget_manager->breakLine(); widget_manager->addImgWgt(WTOK_IMG2, 10, 12, - collectable_manager->getIcon(COLLECT_CAKE)->getState()->getTextureHandle()); + powerup_manager->getIcon(POWERUP_CAKE)->getState()->getTextureHandle()); widget_manager->addTextWgt(WTOK_TXT2, 90, 12, _("Cake - thrown at the closest rival,\nbest on short ranges and long straights")); @@ -73,7 +74,7 @@ widget_manager->breakLine(); widget_manager->addImgWgt(WTOK_IMG3, 10, 12, - collectable_manager->getIcon(COLLECT_BOWLING)->getState()->getTextureHandle()); + powerup_manager->getIcon(POWERUP_BOWLING)->getState()->getTextureHandle()); widget_manager->addTextWgt(WTOK_TXT3, 90, 12, _("Bowling Ball - bounces off walls. If you are looking back,\nit will be thrown backwards.")); @@ -81,7 +82,7 @@ widget_manager->breakLine(); widget_manager->addImgWgt(WTOK_IMG4, 10, 12, - collectable_manager->getIcon(COLLECT_ZIPPER)->getState()->getTextureHandle()); + powerup_manager->getIcon(POWERUP_ZIPPER)->getState()->getTextureHandle()); widget_manager->addTextWgt(WTOK_TXT4, 90, 12, _("Zipper - speed boost")); @@ -89,7 +90,7 @@ widget_manager->breakLine(); widget_manager->addImgWgt(WTOK_IMG5, 10, 12, - collectable_manager->getIcon(COLLECT_PARACHUTE)->getState()->getTextureHandle()); + powerup_manager->getIcon(POWERUP_PARACHUTE)->getState()->getTextureHandle()); widget_manager->addTextWgt(WTOK_TXT5, 90, 12, _("Parachute - slows down all karts in a better position!")); @@ -97,7 +98,7 @@ widget_manager->breakLine(); widget_manager->addImgWgt(WTOK_IMG6, 10, 12, - collectable_manager->getIcon(COLLECT_ANVIL)->getState()->getTextureHandle()); + powerup_manager->getIcon(POWERUP_ANVIL)->getState()->getTextureHandle()); widget_manager->addTextWgt(WTOK_TXT6, 90, 12, _("Anvil - slows down greatly the kart in the first position")); Modified: trunk/supertuxkart/src/gui/race_gui.cpp =================================================================== --- trunk/supertuxkart/src/gui/race_gui.cpp 2008-10-30 01:53:41 UTC (rev 2399) +++ trunk/supertuxkart/src/gui/race_gui.cpp 2008-10-30 02:02:56 UTC (rev 2400) @@ -171,21 +171,21 @@ if (race_manager->getNumPlayers() ==1 ) { Kart* kart = RaceManager::getWorld()->getLocalPlayerKart(0); - kart->setCollectable(COLLECT_BOWLING, 10000); + kart->setPowerup(POWERUP_BOWLING, 10000); } break; case GA_DEBUG_ADD_MISSILE: if (race_manager->getNumPlayers() ==1 ) { Kart* kart = RaceManager::getPlayerKart(0); - kart->setCollectable(COLLECT_MISSILE, 10000); + kart->setPowerup(POWERUP_MISSILE, 10000); } break; case GA_DEBUG_ADD_HOMING: if (race_manager->getNumPlayers() ==1 ) { Kart* kart = RaceManager::getPlayerKart(0); - kart->setCollectable(COLLECT_CAKE, 10000); + kart->setPowerup(POWERUP_CAKE, 10000); } break; case GA_DEBUG_TOGGLE_FPS: @@ -414,22 +414,22 @@ } // drawPlayerIcons //----------------------------------------------------------------------------- -void RaceGUI::drawCollectableIcons ( Kart* player_kart, int offset_x, +void RaceGUI::drawPowerupIcons ( Kart* player_kart, int offset_x, int offset_y, float ratio_x, float ratio_y ) { // If player doesn't have anything, do nothing. - Collectable* collectable=player_kart->getCollectable(); - if(collectable->getType() == COLLECT_NOTHING) return; + Powerup* powerup=player_kart->getPowerup(); + if(powerup->getType() == POWERUP_NOTHING) return; // Originally the hardcoded sizes were 320-32 and 400 int x1 = (int)((user_config->m_width/2-32) * ratio_x) + offset_x ; int y1 = (int)(user_config->m_height*5/6 * ratio_y) + offset_y; int nSize=(int)(64.0f*std::min(ratio_x, ratio_y)); - collectable->getIcon()->apply(); + powerup->getIcon()->apply(); - int n = player_kart->getNumCollectables() ; + int n = player_kart->getNumPowerup() ; if ( n > 5 ) n = 5 ; if ( n < 1 ) n = 1 ; @@ -446,7 +446,7 @@ } // for i glEnd () ; -} // drawCollectableIcons +} // drawPowerupIcons //----------------------------------------------------------------------------- /* Energy meter that gets filled with coins */ @@ -984,7 +984,7 @@ } Kart* player_kart = RaceManager::getWorld()->getLocalPlayerKart(pla); - drawCollectableIcons(player_kart, offset_x, offset_y, + drawPowerupIcons(player_kart, offset_x, offset_y, split_screen_ratio_x, split_screen_ratio_y ); drawEnergyMeter (player_kart, offset_x, offset_y, split_screen_ratio_x, split_screen_ratio_y ); Modified: trunk/supertuxkart/src/gui/race_gui.hpp =================================================================== --- trunk/supertuxkart/src/gui/race_gui.hpp 2008-10-30 01:53:41 UTC (rev 2399) +++ trunk/supertuxkart/src/gui/race_gui.hpp 2008-10-30 02:02:56 UTC (rev 2400) @@ -111,7 +111,7 @@ void drawEnergyMeter (Kart *player_kart, int offset_x, int offset_y, float ratio_x, float ratio_y ); - void drawCollectableIcons (Kart* player_kart, + void drawPowerupIcons (Kart* player_kart, int offset_x, int offset_y, float ratio_x, float ratio_y ); void drawAllMessages (Kart* player_kart, Modified: trunk/supertuxkart/src/ide/Xcode/STK_XCode.xcodeproj/project.pbxproj =================================================================== --- trunk/supertuxkart/src/ide/Xcode/STK_XCode.xcodeproj/project.pbxproj 2008-10-30 01:53:41 UTC (rev 2399) +++ trunk/supertuxkart/src/ide/Xcode/STK_XCode.xcodeproj/project.pbxproj 2008-10-30 02:02:56 UTC (rev 2400) @@ -14,6 +14,10 @@ 9518C11D0EB7AF7A00952372 /* cake.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9518C11B0EB7AF7A00952372 /* cake.cpp */; }; 9518C11E0EB7AF7A00952372 /* cake.hpp in CopyFiles */ = {isa = PBXBuildFile; fileRef = 9518C11C0EB7AF7A00952372 /* cake.hpp */; }; 958EEFB60EB93C03005F6F70 /* item_info.hpp in CopyFiles */ = {isa = PBXBuildFile; fileRef = 958EEFB50EB93C03005F6F70 /* item_info.hpp */; }; + 958EF0130EB94819005F6F70 /* powerup_manager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 958EF00F0EB94818005F6F70 /* powerup_manager.cpp */; }; + 958EF0140EB94819005F6F70 /* powerup_manager.hpp in CopyFiles */ = {isa = PBXBuildFile; fileRef = 958EF0100EB94819005F6F70 /* powerup_manager.hpp */; }; + 958EF0150EB94819005F6F70 /* powerup.hpp in CopyFiles */ = {isa = PBXBuildFile; fileRef = 958EF0110EB94819005F6F70 /* powerup.hpp */; }; + 958EF0160EB94819005F6F70 /* powerup.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 958EF0120EB94819005F6F70 /* powerup.cpp */; }; 95B0CF470EB69DDA001A0D06 /* actionmap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 95B0C9E90EB69DCE001A0D06 /* actionmap.cpp */; }; 95B0CF480EB69DDA001A0D06 /* actionmap.hpp in CopyFiles */ = {isa = PBXBuildFile; fileRef = 95B0C9EA0EB69DCE001A0D06 /* actionmap.hpp */; }; 95B0CF490EB69DDA001A0D06 /* music.hpp in CopyFiles */ = {isa = PBXBuildFile; fileRef = 95B0C9EC0EB69DCE001A0D06 /* music.hpp */; }; @@ -390,10 +394,6 @@ 95B0D35B0EB69DDF001A0D06 /* attachment_manager.hpp in CopyFiles */ = {isa = PBXBuildFile; fileRef = 95B0CE2A0EB69DD9001A0D06 /* attachment_manager.hpp */; }; 95B0D35C0EB69DDF001A0D06 /* bowling.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 95B0CE2B0EB69DD9001A0D06 /* bowling.cpp */; }; 95B0D35D0EB69DDF001A0D06 /* bowling.hpp in CopyFiles */ = {isa = PBXBuildFile; fileRef = 95B0CE2C0EB69DD9001A0D06 /* bowling.hpp */; }; - 95B0D35E0EB69DDF001A0D06 /* collectable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 95B0CE2D0EB69DD9001A0D06 /* collectable.cpp */; }; - 95B0D35F0EB69DDF001A0D06 /* collectable.hpp in CopyFiles */ = {isa = PBXBuildFile; fileRef = 95B0CE2E0EB69DD9001A0D06 /* collectable.hpp */; }; - 95B0D3600EB69DDF001A0D06 /* collectable_manager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 95B0CE2F0EB69DD9001A0D06 /* collectable_manager.cpp */; }; - 95B0D3610EB69DDF001A0D06 /* collectable_manager.hpp in CopyFiles */ = {isa = PBXBuildFile; fileRef = 95B0CE300EB69DD9001A0D06 /* collectable_manager.hpp */; }; 95B0D3680EB69DDF001A0D06 /* missile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 95B0CE370EB69DD9001A0D06 /* missile.cpp */; }; 95B0D3690EB69DDF001A0D06 /* missile.hpp in CopyFiles */ = {isa = PBXBuildFile; fileRef = 95B0CE380EB69DD9001A0D06 /* missile.hpp */; }; 95B0D36A0EB69DDF001A0D06 /* projectile_manager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 95B0CE390EB69DD9001A0D06 /* projectile_manager.cpp */; }; @@ -754,8 +754,6 @@ 95B0D3590EB69DDF001A0D06 /* attachment.hpp in CopyFiles */, 95B0D35B0EB69DDF001A0D06 /* attachment_manager.hpp in CopyFiles */, 95B0D35D0EB69DDF001A0D06 /* bowling.hpp in CopyFiles */, - 95B0D35F0EB69DDF001A0D06 /* collectable.hpp in CopyFiles */, - 95B0D3610EB69DDF001A0D06 /* collectable_manager.hpp in CopyFiles */, 95B0D3690EB69DDF001A0D06 /* missile.hpp in CopyFiles */, 95B0D36B0EB69DDF001A0D06 /* projectile_manager.hpp in CopyFiles */, 95B0D36E0EB69DDF001A0D06 /* kart.hpp in CopyFiles */, @@ -832,6 +830,8 @@ 95090A4A0EB7EA960048841A /* item.hpp in CopyFiles */, 95090A4B0EB7EA960048841A /* item_manager.hpp in CopyFiles */, 958EEFB60EB93C03005F6F70 /* item_info.hpp in CopyFiles */, + 958EF0140EB94819005F6F70 /* powerup_manager.hpp in CopyFiles */, + 958EF0150EB94819005F6F70 /* powerup.hpp in CopyFiles */, ); runOnlyForDeploymentPostprocessing = 1; }; @@ -845,6 +845,10 @@ 9518C11B0EB7AF7A00952372 /* cake.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cake.cpp; sourceTree = "<group>"; }; 9518C11C0EB7AF7A00952372 /* cake.hpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.h; path = cake.hpp; sourceTree = "<group>"; }; 958EEFB50EB93C03005F6F70 /* item_info.hpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.h; path = item_info.hpp; sourceTree = "<group>"; }; + 958EF00F0EB94818005F6F70 /* powerup_manager.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = powerup_manager.cpp; sourceTree = "<group>"; }; + 958EF0100EB94819005F6F70 /* powerup_manager.hpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.h; path = powerup_manager.hpp; sourceTree = "<group>"; }; + 958EF0110EB94819005F6F70 /* powerup.hpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.h; path = powerup.hpp; sourceTree = "<group>"; }; + 958EF0120EB94819005F6F70 /* powerup.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = powerup.cpp; sourceTree = "<group>"; }; 95B0C9E90EB69DCE001A0D06 /* actionmap.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = actionmap.cpp; sourceTree = "<group>"; }; 95B0C9EA0EB69DCE001A0D06 /* actionmap.hpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.h; path = actionmap.hpp; sourceTree = "<group>"; }; 95B0C9EC0EB69DCE001A0D06 /* music.hpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.h; path = music.hpp; sourceTree = "<group>"; }; @@ -1221,10 +1225,6 @@ 95B0CE2A0EB69DD9001A0D06 /* attachment_manager.hpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.h; path = attachment_manager.hpp; sourceTree = "<group>"; }; 95B0CE2B0EB69DD9001A0D06 /* bowling.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = bowling.cpp; sourceTree = "<group>"; }; 95B0CE2C0EB69DD9001A0D06 /* bowling.hpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.h; path = bowling.hpp; sourceTree = "<group>"; }; - 95B0CE2D0EB69DD9001A0D06 /* collectable.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = collectable.cpp; sourceTree = "<group>"; }; - 95B0CE2E0EB69DD9001A0D06 /* collectable.hpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.h; path = collectable.hpp; sourceTree = "<group>"; }; - 95B0CE2F0EB69DD9001A0D06 /* collectable_manager.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = collectable_manager.cpp; sourceTree = "<group>"; }; - 95B0CE300EB69DD9001A0D06 /* collectable_manager.hpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.h; path = collectable_manager.hpp; sourceTree = "<group>"; }; 95B0CE370EB69DD9001A0D06 /* missile.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = missile.cpp; sourceTree = "<group>"; }; 95B0CE380EB69DD9001A0D06 /* missile.hpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.h; path = missile.hpp; sourceTree = "<group>"; }; 95B0CE390EB69DD9001A0D06 /* projectile_manager.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = projectile_manager.cpp; sourceTree = "<group>"; }; @@ -2290,6 +2290,10 @@ 95B0CE260EB69DD9001A0D06 /* items */ = { isa = PBXGroup; children = ( + 958EF00F0EB94818005F6F70 /* powerup_manager.cpp */, + 958EF0100EB94819005F6F70 /* powerup_manager.hpp */, + 958EF0110EB94819005F6F70 /* powerup.hpp */, + 958EF0120EB94819005F6F70 /* powerup.cpp */, 9518C11B0EB7AF7A00952372 /* cake.cpp */, 9518C11C0EB7AF7A00952372 /* cake.hpp */, 95B0CE270EB69DD9001A0D06 /* attachment.cpp */, @@ -2298,10 +2302,6 @@ 95B0CE2A0EB69DD9001A0D06 /* attachment_manager.hpp */, 95B0CE2B0EB69DD9001A0D06 /* bowling.cpp */, 95B0CE2C0EB69DD9001A0D06 /* bowling.hpp */, - 95B0CE2D0EB69DD9001A0D06 /* collectable.cpp */, - 95B0CE2E0EB69DD9001A0D06 /* collectable.hpp */, - 95B0CE2F0EB69DD9001A0D06 /* collectable_manager.cpp */, - 95B0CE300EB69DD9001A0D06 /* collectable_manager.hpp */, 95090A450EB7EA960048841A /* item.cpp */, 95090A460EB7EA960048841A /* item.hpp */, 95090A470EB7EA960048841A /* item_manager.hpp */, @@ -2953,8 +2953,6 @@ 95B0D3580EB69DDF001A0D06 /* attachment.cpp in Sources */, 95B0D35A0EB69DDF001A0D06 /* attachment_manager.cpp in Sources */, 95B0D35C0EB69DDF001A0D06 /* bowling.cpp in Sources */, - 95B0D35E0EB69DDF001A0D06 /* collectable.cpp in Sources */, - 95B0D3600EB69DDF001A0D06 /* collectable_manager.cpp in Sources */, 95B0D3680EB69DDF001A0D06 /* missile.cpp in Sources */, 95B0D36A0EB69DDF001A0D06 /* projectile_manager.cpp in Sources */, 95B0D36C0EB69DDF001A0D06 /* kart.cpp in Sources */, @@ -3017,6 +3015,8 @@ 9518C11D0EB7AF7A00952372 /* cake.cpp in Sources */, 95090A490EB7EA960048841A /* item.cpp in Sources */, 95090A4C0EB7EA960048841A /* item_manager.cpp in Sources */, + 958EF0130EB94819005F6F70 /* powerup_manager.cpp in Sources */, + 958EF0160EB94819005F6F70 /* powerup.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; Modified: trunk/supertuxkart/src/items/bowling.cpp =================================================================== --- trunk/supertuxkart/src/items/bowling.cpp 2008-10-30 01:53:41 UTC (rev 2399) +++ trunk/supertuxkart/src/items/bowling.cpp 2008-10-30 02:02:56 UTC (rev 2400) @@ -26,7 +26,7 @@ float Bowling::m_st_force_to_target; // ----------------------------------------------------------------------------- -Bowling::Bowling(Kart *kart) : Flyable(kart, COLLECT_BOWLING, 50.0f /* mass */) +Bowling::Bowling(Kart *kart) : Flyable(kart, POWERUP_BOWLING, 50.0f /* mass */) { float y_offset = 0.5f*kart->getKartLength()+2.0f*m_extend.getY(); @@ -65,7 +65,7 @@ // ----------------------------------------------------------------------------- void Bowling::init(const lisp::Lisp* lisp, ssgEntity *bowling) { - Flyable::init(lisp, bowling, COLLECT_BOWLING); + Flyable::init(lisp, bowling, POWERUP_BOWLING); m_st_max_distance = 20.0f; m_st_max_distance_squared = 20.0f * 20.0f; m_st_force_to_target = 10.0f; Modified: trunk/supertuxkart/src/items/cake.cpp =================================================================== --- trunk/supertuxkart/src/items/cake.cpp 2008-10-30 01:53:41 UTC (rev 2399) +++ trunk/supertuxkart/src/items/cake.cpp 2008-10-30 02:02:56 UTC (rev 2400) @@ -26,7 +26,7 @@ float Cake::m_st_max_distance_squared; float Cake::m_st_max_turn_angle; -Cake::Cake (Kart *kart) : Flyable(kart, COLLECT_CAKE) +Cake::Cake (Kart *kart) : Flyable(kart, POWERUP_CAKE) { m_target = NULL; @@ -112,7 +112,7 @@ // ----------------------------------------------------------------------------- void Cake::init(const lisp::Lisp* lisp, ssgEntity *cake_model) { - Flyable::init(lisp, cake_model, COLLECT_CAKE); + Flyable::init(lisp, cake_model, POWERUP_CAKE); m_st_max_turn_angle = 15.0f; m_st_max_distance = 80.0f; m_st_max_distance_squared = 80.0f * 80.0f; Deleted: trunk/supertuxkart/src/items/collectable.cpp =================================================================== --- trunk/supertuxkart/src/items/collectable.cpp 2008-10-30 01:53:41 UTC (rev 2399) +++ trunk/supertuxkart/src/items/collectable.cpp 2008-10-30 02:02:56 UTC (rev 2400) @@ -1,257 +0,0 @@ -// $Id$ -// -// SuperTuxKart - a fun racing game with go-kart -// Copyright (C) 2006 Joerg Henrichs -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 3 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#include "items/collectable.hpp" - -#include "network/network_manager.hpp" -#include "network/race_state.hpp" -#include "user_config.hpp" -#include "race_manager.hpp" -#include "items/projectile_manager.hpp" -#include "kart.hpp" -#include "audio/sfx_manager.hpp" -#include "audio/sfx_base.hpp" -#include "modes/world.hpp" -#include "stk_config.hpp" - -//----------------------------------------------------------------------------- -Collectable::Collectable(Kart* kart_) -{ - m_owner = kart_; - m_sound_shot = sfx_manager->newSFX(SFXManager::SOUND_SHOT); - m_sound_use_anvil = sfx_manager->newSFX(SFXManager::SOUND_USE_ANVIL); - m_sound_use_parachute = sfx_manager->newSFX(SFXManager::SOUND_USE_PARACHUTE); - reset(); -} // Collectable - -//----------------------------------------------------------------------------- -/** Frees the memory for the sound effects. - */ -Collectable::~Collectable() -{ - sfx_manager->deleteSFX(m_sound_shot); - sfx_manager->deleteSFX(m_sound_use_anvil); - sfx_manager->deleteSFX(m_sound_use_parachute); - -} // ~Collectable - -//----------------------------------------------------------------------------- -void Collectable::reset() -{ - int type; - RaceManager::getWorld()->getDefaultCollectibles( type, m_number ); - m_type = (CollectableType)type; -} // reset - -//----------------------------------------------------------------------------- -void Collectable::set(CollectableType type, int n) -{ - if (m_type==type) - { - m_number+=n; - return; - } - m_type=type; - m_number=n; -} // set - -//----------------------------------------------------------------------------- -Material *Collectable::getIcon() -{ - // Check if it's one of the types which have a separate - // data file which includes the icon: - return collectable_manager->getIcon(m_type); -} - -//----------------------------------------------------------------------------- -void Collectable::use() -{ - m_number--; - switch (m_type) - { - case COLLECT_ZIPPER: m_owner->handleZipper(); - break ; - case COLLECT_CAKE: - case COLLECT_BOWLING: - case COLLECT_MISSILE: - m_sound_shot->position(m_owner->getXYZ()); - m_sound_shot->play(); - projectile_manager->newProjectile(m_owner, m_type); - break ; - - case COLLECT_ANVIL: - //Attach an anvil(twice as good as the one given - //by the bananas) to the kart in the 1st position. - for(unsigned int i = 0 ; i < race_manager->getNumKarts(); ++i) - { - Kart *kart=RaceManager::getKart(i); - if(kart->isEliminated()) continue; - if(kart == m_owner) continue; - if(kart->getPosition() == 1) - { - kart->attach(ATTACH_ANVIL, stk_config->m_anvil_time); - kart->adjustSpeedWeight(stk_config->m_anvil_speed_factor*0.5f); - m_sound_use_anvil->position(m_owner->getXYZ()); - m_sound_use_anvil->play(); - break; - } - } - - break; - - case COLLECT_PARACHUTE: - { - Kart* player_kart = NULL; - //Attach a parachutte(that last as twice as the - //one from the bananas) to all the karts that - //are in front of this one. - for(unsigned int i = 0 ; i < race_manager->getNumKarts(); ++i) - { - Kart *kart=RaceManager::getKart(i); - if(kart->isEliminated() || kart== m_owner) continue; - if(m_owner->getPosition() > kart->getPosition()) - { - kart->attach(ATTACH_PARACHUTE, stk_config->m_parachute_time_other); - - if(kart->isPlayerKart()) - player_kart = kart; - } - } - - if(player_kart) - { - m_sound_use_parachute->position(player_kart->getXYZ()); - m_sound_use_parachute->play(); - } - } - break; - - case COLLECT_NOTHING: - default : break ; - } - - if ( m_number <= 0 ) - { - m_number = 0; - m_type = COLLECT_NOTHING; - } -} // use - -//----------------------------------------------------------------------------- -void Collectable::hitBonusBox(int n, const Item &item, int add_info) -{ - //The probabilities of getting the anvil or the parachute increase - //depending on how bad the owner's position is. For the first - //driver the posibility is none, for the last player is 15 %. - if(m_owner->getPosition() != 1 && m_type == COLLECT_NOTHING) - { - // On client: just set the value - if(network_manager->getMode()==NetworkManager::NW_CLIENT) - { - m_random.get(100); // keep random numbers in sync - m_type = (CollectableType)add_info; - m_number = 1; - return; - } - const int SPECIAL_PROB = (int)(15.0 / ((float)RaceManager::getWorld()->getCurrentNumKarts() / - (float)m_owner->getPosition())); - const int RAND_NUM = m_random.get(100); - if(RAND_NUM <= SPECIAL_PROB) - { - //If the driver in the first position has finished, give the driver - //the parachute. - for(unsigned int i=0; i < race_manager->getNumKarts(); ++i) - { - Kart *kart = RaceManager::getKart(i); - if(kart->isEliminated() || kart == m_owner) continue; - if(kart->getPosition() == 1 && kart->hasFinishedRace()) - { - m_type = COLLECT_PARACHUTE; - m_number = 1; - if(network_manager->getMode()==NetworkManager::NW_SERVER) - { - race_state->itemCollected(m_owner->getWorldKartId(), - item.getItemId(), - m_type); - } - return; - } - } - - m_type = m_random.get(2) == 0 ? COLLECT_ANVIL : COLLECT_PARACHUTE; - m_number = 1; - if(network_manager->getMode()==NetworkManager::NW_SERVER) - { - race_state->itemCollected(m_owner->getWorldKartId(), - item.getItemId(), - (char)m_type); - } - return; - } - } - - - // If no special case is done: on the client just adjust the number - // dependent on the server informaion: - if(network_manager->getMode()==NetworkManager::NW_CLIENT) - { - if(m_type==COLLECT_NOTHING) - { - m_type = (CollectableType)add_info; - m_number = n; - } - else if((CollectableType)add_info==m_type) - { - m_number+=n; - if(m_number > MAX_COLLECTABLES) m_number = MAX_COLLECTABLES; - } - // Ignore new collectable if it is different from the current one - m_random.get(100); // keep random numbers in synch - - return; - } // if network client - - // Otherwise (server or no network): determine collectable randomly - - //rand() is moduled by COLLECT_MAX - 1 - 2 because because we have to - //exclude the anvil and the parachute, but later we have to add 1 to prevent - //having a value of 0 since that isn't a valid collectable. - CollectableType newC; - newC = (CollectableType)(m_random.get(COLLECT_MAX - 1 - 2) + 1); - // Save the information about the collectable in the race state - // so that the clients can be updated. - if(network_manager->getMode()==NetworkManager::NW_SERVER) - { - race_state->itemCollected(m_owner->getWorldKartId(), - item.getItemId(), - newC); - } - - if(m_type==COLLECT_NOTHING) - { - m_type=newC; - m_number = n; - } - else if(newC==m_type) - { - m_number+=n; - if(m_number > MAX_COLLECTABLES) m_number = MAX_COLLECTABLES; - } - // Ignore new collectable if it is different from the current one -} // hitBonusBox Deleted: trunk/supertuxkart/src/items/collectable.hpp =================================================================== --- trunk/supertuxkart/src/items/collectable.hpp 2008-10-30 01:53:41 UTC (rev 2399) +++ trunk/supertuxkart/src/items/collectable.hpp 2008-10-30 02:02:56 UTC (rev 2400) @@ -1,57 +0,0 @@ -// $Id$ -// -// SuperTuxKart - a fun racing game with go-kart -// Copyright (C) 2006 Joerg Henrichs -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 3 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#ifndef HEADER_COLLECTABLE_H -#define HEADER_COLLECTABLE_H - -#define MAX_COLLECTABLES 5 - -#include "items/collectable_manager.hpp" // needed for collectable_type -#include "utils/random_generator.hpp" - -class Kart; -class Item; -class SFXBase; - -class Collectable -{ -private: - RandomGenerator m_random; - SFXBase *m_sound_shot; - SFXBase *m_sound_use_anvil; - SFXBase *m_sound_use_parachute; - -protected: - Kart* m_owner; - CollectableType m_type; - int m_number; - -public: - Collectable (Kart* kart_); - ~Collectable (); - void set (CollectableType _type, int n=1); - void reset (); - int getNum () const {return m_number;} - CollectableType getType () const {return m_type; } - void hitBonusBox (int n, const Item &item, int newC=-1); - Material* getIcon (); - void use (); -}; - -#endif Deleted: trunk/supertuxkart/src/items/collectable_manager.cpp =================================================================== --- trunk/supertuxkart/src/items/collectable_manager.cpp 2008-10-30 01:53:41 UTC (rev 2399) +++ trunk/supertuxkart/src/items/collectable_manager.cpp 2008-10-30 02:02:56 UTC (rev 2400) @@ -1,148 +0,0 @@ -// $Id$ -// -// SuperTuxKart - a fun racing game with go-kart -// Copyright (C) 2006 Joerg Henrichs -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 3 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#include <iostream> -#include <stdexcept> -#include "items/collectable_manager.hpp" -#include "file_manager.hpp" -#include "material_manager.hpp" -#include "material.hpp" -#include "translation.hpp" -#include "items/bowling.hpp" -#include "missile.hpp" -#include "items/cake.hpp" -#include "loader.hpp" - -#if defined(WIN32) && !defined(__CYGWIN__) -# define snprintf _snprintf -#endif - -typedef struct -{ - CollectableType collectable; - const char*const dataFile; -} -initCollectableType; - -initCollectableType ict[]= -{ - {COLLECT_ZIPPER, "zipper.collectable" }, - {COLLECT_BOWLING, "bowling.projectile" }, - {COLLECT_MISSILE, "missile.projectile" }, - {COLLECT_CAKE, "cake.projectile" }, - {COLLECT_ANVIL, "anvil.collectable" }, - {COLLECT_PARACHUTE, "parachute.collectable" }, - {COLLECT_MAX, "" }, -}; - -CollectableManager* collectable_manager=0; - -//----------------------------------------------------------------------------- -CollectableManager::CollectableManager() -{ - for(int i=0; i<COLLECT_MAX; i++) - { - m_all_models[i] = (ssgEntity*)NULL; - m_all_icons[i] = (Material*)NULL; - } -} // CollectableManager - -//----------------------------------------------------------------------------- -void CollectableManager::removeTextures() -{ - for(int i=0; i<COLLECT_MAX; i++) - { - if(m_all_icons [i]) ssgDeRefDelete(m_all_icons [i]->getState()); - if(m_all_models[i]) ssgDeRefDelete(m_all_models[i] ); - } // for - callback_manager->clear(CB_COLLECTABLE); - -} // removeTextures - -//----------------------------------------------------------------------------- -void CollectableManager::loadCollectables() -{ - for(int i=0; ict[i].collectable != COLLECT_MAX; i++) - { - Load(ict[i].collectable, ict[i].dataFile); - } -} // loadCollectables - -//----------------------------------------------------------------------------- -void CollectableManager::Load(int collectType, const char* filename) -{ - const lisp::Lisp* ROOT = 0; - - lisp::Parser parser; - std::string tmp= "data/" + (std::string)filename; - ROOT = parser.parse(file_manager->getConfigFile(filename)); - - const lisp::Lisp* lisp = ROOT->getLisp("tuxkart-collectable"); - if(!lisp) - { - char msg[MAX_ERROR_MESSAGE_LENGTH]; - snprintf(msg, sizeof(msg), - "No 'tuxkart-collectable' node found while parsing '%s'.", - filename); - throw std::runtime_error(msg); - } - LoadNode(lisp, collectType); - - delete ROOT; - -} // Load - -//----------------------------------------------------------------------------- -void CollectableManager::LoadNode(const lisp::Lisp* lisp, int collectType ) -{ - std::string sName, sModel, sIconFile; - lisp->get("name", sName ); - lisp->get("model", sModel ); - lisp->get("icon", sIconFile ); - - // load material - m_all_icons[collectType] = material_manager->getMaterial(sIconFile); - m_all_icons[collectType]->getState()->ref(); - - if(sModel!="") - { - ssgEntity* e = loader->load(sModel, CB_COLLECTABLE); - m_all_models[collectType] = e; - e->ref(); - e->clrTraversalMaskBits(SSGTRAV_ISECT|SSGTRAV_HOT); - } - else - { - m_all_models[collectType] = 0; - m_all_extends[collectType] = btVector3(0.0f,0.0f,0.0f); - } - - // Load special attributes for certain collectables - switch (collectType) { - case COLLECT_BOWLING: - Bowling::init (lisp, m_all_models[collectType]); break; - case COLLECT_MISSILE: - Missile::init(lisp, m_all_models[collectType]); break; - case COLLECT_CAKE: - Cake::init (lisp, m_all_models[collectType]); break; - default:; - } // switch - -} // LoadNode - Deleted: trunk/supertuxkart/src/items/collectable_manager.hpp =================================================================== --- trunk/supertuxkart/src/items/collectable_manager.hpp 2008-10-30 01:53:41 UTC (rev 2399) +++ trunk/supertuxkart/src/items/collectable_manager.hpp 2008-10-30 02:02:56 UTC (rev 2400) @@ -1,64 +0,0 @@ -// $Id$ -// -// SuperTuxKart - a fun racing game with go-kart -// Copyright (C) 2006 Joerg Henrichs -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 3 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#ifndef HEADER_COLLECTABLEMANAGER_H -#define HEADER_COLLECTABLEMANAGER_H - -#include "lisp/parser.hpp" -#include "lisp/lisp.hpp" -#include "btBulletDynamicsCommon.h" - -class Material; -class ssgEntity; - -// The anvil and parachute must be at the end of the enum, and the -// zipper just before them (see collectable::hitBonusBox). -enum CollectableType {COLLECT_NOTHING, - COLLECT_MISSILE, COLLECT_CAKE, - COLLECT_BOWLING, COLLECT_ZIPPER, - COLLECT_PARACHUTE, COLLECT_ANVIL, - COLLECT_MAX}; - -class CollectableManager -{ -protected: - Material* m_all_icons [COLLECT_MAX]; - float m_all_max_distance[COLLECT_MAX]; // if a target is closer than this - float m_all_force_to_target[COLLECT_MAX]; // apply this force to move towards - // the target - float m_all_max_turn_angle[COLLECT_MAX]; // maximum turn angle for homing - ssgEntity* m_all_models[COLLECT_MAX]; - btVector3 m_all_extends[COLLECT_MAX]; - void LoadNode (const lisp::Lisp* lisp, int collectType); -public: - CollectableManager (); - void loadCollectables(); - void removeTextures (); - void Load (int collectType, const char* filename); - Material* getIcon (int type) const {return m_all_icons [type]; } - ssgEntity* getModel (int type) const {return m_all_models[type]; } - float getForceToTarget(int type) const {return m_all_force_to_target[type]; } - float getMaxDistance (int type) const {return m_all_max_distance[type];} - float getMaxTurnAngle (int type) const {return m_all_max_turn_angle[type];} - const btVector3& getExtend (int type) const {return m_all_extends[type]; } -}; - -extern CollectableManager* collectable_manager; - -#endif Modified: trunk/supertuxkart/src/items/missile.cpp =================================================================== --- trunk/supertuxkart/src/items/missile.cpp 2008-10-30 01:53:41 UTC (rev 2399) +++ trunk/supertuxkart/src/items/missile.cpp 2008-10-30 02:02:56 UTC (rev 2400) @@ -21,7 +21,7 @@ #include "constants.hpp" // ----------------------------------------------------------------------------- -Missile::Missile(Kart *kart) : Flyable(kart, COLLECT_MISSILE) +Missile::Missile(Kart *kart) : Flyable(kart, POWERUP_MISSILE) { float y_offset=kart->getKartLength()+2.0f*m_extend.getY(); createPhysics(y_offset, btVector3(0.0f, m_speed, 0.0f), @@ -31,7 +31,7 @@ // ----------------------------------------------------------------------------- void Missile::init(const lisp::Lisp* lisp, ssgEntity *missile) { - Flyable::init(lisp, missile, COLLECT_MISSILE); + Flyable::init(lisp, missile, POWERUP_MISSILE); } // init // ----------------------------------------------------------------------------- Copied: trunk/supertuxkart/src/items/powerup.cpp (from rev 2392, trunk/supertuxkart/src/items/collectable.cpp) =================================================================== --- trunk/supertuxkart/src/items/powerup.cpp (rev 0) +++ trunk/supertuxkart/src/items/powerup.cpp 2008-10-30 02:02:56 UTC (rev 2400) @@ -0,0 +1,257 @@ +// $Id$ +// +// SuperTuxKart - a fun racing game with go-kart +// Copyright (C) 2006 Joerg Henrichs +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 3 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#include "items/powerup.hpp" + +#include "network/network_manager.hpp" +#include "network/race_state.hpp" +#include "user_config.hpp" +#include "race_manager.hpp" +#include "items/projectile_manager.hpp" +#include "kart.hpp" +#include "audio/sfx_manager.hpp" +#include "audio/sfx_base.hpp" +#include "modes/world.hpp" +#include "stk_config.hpp" + +//----------------------------------------------------------------------------- +Powerup::Powerup(Kart* kart_) +{ + m_owner = kart_; + m_sound_shot = sfx_manager->newSFX(SFXManager::SOUND_SHOT); + m_sound_use_anvil = sfx_manager->newSFX(SFXManager::SOUND_USE_ANVIL); + m_sound_use_parachute = sfx_manager->newSFX(SFXManager::SOUND_USE_PARACHUTE); + reset(); +} // Powerup + +//----------------------------------------------------------------------------- +/** Frees the memory for the sound effects. + */ +Powerup::~Powerup() +{ + sfx_manager->deleteSFX(m_sound_shot); + sfx_manager->deleteSFX(m_sound_use_anvil); + sfx_manager->deleteSFX(m_sound_use_parachute); + +} // ~Powerup + +//----------------------------------------------------------------------------- +void Powerup::reset() +{ + int type; + RaceManager::getWorld()->getDefaultCollectibles( type, m_number ); + m_type = (PowerupType)type; +} // reset + +//----------------------------------------------------------------------------- +void Powerup::set(PowerupType type, int n) +{ + if (m_type==type) + { + m_number+=n; + return; + } + m_type=type; + m_number=n; +} // set + +//----------------------------------------------------------------------------- +Material *Powerup::getIcon() +{ + // Check if it's one of the types which have a separate + // data file which includes the icon: + return powerup_manager->getIcon(m_type); +} + +//----------------------------------------------------------------------------- +void Powerup::use() +{ + m_number--; + switch (m_type) + { + case POWERUP_ZIPPER: m_owner->handleZipper(); + break ; + case POWERUP_CAKE: + case POWERUP_BOWLING: + case POWERUP_MISSILE: + m_sound_shot->position(m_owner->getXYZ()); + m_sound_shot->play(); + projectile_manager->newProjectile(m_owner, m_type); + break ; + + case POWERUP_ANVIL: + //Attach an anvil(twice as good as the one given + //by the bananas) to the kart in the 1st position. + for(unsigned int i = 0 ; i < race_manager->getNumKarts(); ++i) + { + Kart *kart=RaceManager::getKart(i); + if(kart->isEliminated()) continue; + if(kart == m_owner) continue; + if(kart->getPosition() == 1) + { + kart->attach(ATTACH_ANVIL, stk_config->m_anvil_time); + kart->adjustSpeedWeight(stk_config->m_anvil_speed_factor*0.5f); + m_sound_use_anvil->position(m_owner->getXYZ()); + m_sound_use_anvil->play(); + break; + } + } + + break; + + case POWERUP_PARACHUTE: + { + Kart* player_kart = NULL; + //Attach a parachutte(that last as twice as the + //one from the bananas) to all the karts that + //are in front of this one. + for(unsigned int i = 0 ; i < race_manager->getNumKarts(); ++i) + { + Kart *kart=RaceManager::getKart(i); + if(kart->isEliminated() || kart== m_owner) continue; + if(m_owner->getPosition() > kart->getPosition()) + { + kart->attach(ATTACH_PARACHUTE, stk_config->m_parachute_time_other); + + if(kart->isPlayerKart()) + player_kart = kart; + } + } + + if(player_kart) + { + m_sound_use_parachute->position(player_kart->getXYZ()); + m_sound_use_parachute->play(); + } + } + break; + + case POWERUP_NOTHING: + default : break ; + } + + if ( m_number <= 0 ) + { + m_number = 0; + m_type = POWERUP_NOTHING; + } +} // use + +//----------------------------------------------------------------------------- +void Powerup::hitBonusBox(int n, const Item &item, int add_info) +{ + //The probabilities of getting the anvil or the parachute increase + //depending on how bad the owner's position is. For the first + //driver the posibility is none, for the last player is 15 %. + if(m_owner->getPosition() != 1 && m_type == POWERUP_NOTHING) + { + // On client: just set the value + if(network_manager->getMode()==NetworkManager::NW_CLIENT) + { + m_random.get(100); // keep random numbers in sync + m_type = (PowerupType)add_info; + m_number = 1; + return; + } + const int SPECIAL_PROB = (int)(15.0 / ((float)RaceManager::getWorld()->getCurrentNumKarts() / + (float)m_owner->getPosition())); + const int RAND_NUM = m_random.get(100); + if(RAND_NUM <= SPECIAL_PROB) + { + //If the driver in the first position has finished, give the driver + //the parachute. + for(unsigned int i=0; i < race_manager->getNumKarts(); ++i) + { + Kart *kart = RaceManager::getKart(i); + if(kart->isEliminated() || kart == m_owner) continue; + if(kart->getPosition() == 1 && kart->hasFinishedRace()) + { + m_type = POWERUP_PARACHUTE; + m_number = 1; + if(network_manager->getMode()==NetworkManager::NW_SERVER) + { + race_state->itemCollected(m_owner->getWorldKartId(), + item.getItemId(), + m_type); + } + return; + } + } + + m_type = m_random.get(2) == 0 ? POWERUP_ANVIL : POWERUP_PARACHUTE; + m_number = 1; + if(network_manager->getMode()==NetworkManager::NW_SERVER) + { + race_state->itemCollected(m_owner->getWorldKartId(), + item.getItemId(), + (char)m_type); + } + return; + } + } + + + // If no special case is done: on the client just adjust the number + // dependent on the server informaion: + if(network_manager->getMode()==NetworkManager::NW_CLIENT) + { + if(m_type==POWERUP_NOTHING) + { + m_type = (PowerupType)add_info; + m_number = n; + } + else if((PowerupType)add_info==m_type) + { + m_number+=n; + if(m_number > MAX_POWERUPS) m_number = MAX_POWERUPS; + } + // Ignore new powerup if it is different from the current one + m_random.get(100); // keep random numbers in synch + + return; + } // if network client + + // Otherwise (server or no network): determine powerup randomly + + //rand() is moduled by POWERUP_MAX - 1 - 2 because because we have to + //exclude the anvil and the parachute, but later we have to add 1 to prevent + //having a value of 0 since that isn't a valid powerup. + PowerupType newC; + newC = (PowerupType)(m_random.get(POWERUP_MAX - 1 - 2) + 1); + // Save the information about the powerup in the race state + // so that the clients can be updated. + if(network_manager->getMode()==NetworkManager::NW_SERVER) + { + race_state->itemCollected(m_owner->getWorldKartId(), + item.getItemId(), + newC); + } + + if(m_type==POWERUP_NOTHING) + { + m_type=newC; + m_number = n; + } + else if(newC==m_type) + { + m_number+=n; + if(m_number > MAX_POWERUPS) m_number = MAX_POWERUPS; + } + // Ignore new powerup if it is different from the current one +} // hitBonusBox Copied: trunk/supertuxkart/src/items/powerup.hpp (from rev 2392, trunk/supertuxkart/src/items/collectable.hpp) =================================================================== --- trunk/supertuxkart/src/items/powerup.hpp (rev 0) +++ trunk/supertuxkart/src/items/powerup.hpp 2008-10-30 02:02:56 UTC (rev 2400) @@ -0,0 +1,57 @@ +// $Id$ +// +// SuperTuxKart - a fun racing game with go-kart +// Copyright (C) 2006 Joerg Henrichs +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 3 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#ifndef HEADER_POWERUP_H +#define HEADER_POWERUP_H + +#define MAX_POWERUPS 5 + +#include "items/powerup_manager.hpp" // needed for powerup_type +#include "utils/random_generator.hpp" + +class Kart; +class Item; +class SFXBase; + +class Powerup +{ +private: + RandomGenerator m_random; + SFXBase *m_sound_shot; + SFXBase *m_sound_use_anvil; + SFXBase *m_sound_use_parachute; + +protected: + Kart* m_owner; + PowerupType m_type; + int m_number; + +public: + Powerup (Kart* kart_); + ~Powerup (); + void set (PowerupType _type, int n=1); + void reset (); + int getNum () const {return m_number;} + PowerupType getType () const {return m_type; } + void hitBonusBox (int n, const Item &item, int newC=-1); + Material* getIcon (); + void use (); +}; + +#endif Copied: trunk/supertuxkart/src/items/powerup_manager.cpp (from rev 2391, trunk/supertuxkart/src/items/collectable_manager.cpp) =================================================================== --- trunk/supertuxkart/src/items/powerup_manager.cpp (rev 0) +++ trunk/supertuxkart/src/items/powerup_manager.cpp 2008-10-30 02:02:56 UTC (rev 2400) @@ -0,0 +1,148 @@ +// $Id$ +// +// SuperTuxKart - a fun racing game with go-kart +// Copyright (C) 2006 Joerg Henrichs +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 3 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#include <iostream> +#include <stdexcept> +#include "items/powerup_manager.hpp" +#include "file_manager.hpp" +#include "material_manager.hpp" +#include "material.hpp" +#include "translation.hpp" +#include "items/bowling.hpp" +#include "missile.hpp" +... [truncated message content] |