From ea07179d46e15141a3eb6eb7236e030f11692751 Mon Sep 17 00:00:00 2001 From: auria Date: Wed, 3 Dec 2008 16:03:32 +0000 Subject: [PATCH] added new bowling ball sounds, and cleaned up powrup sounds to make it easier to use different sounds for different weapons while instanciating less objects git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@2564 178a84e3-b1eb-0310-8ba1-8eac791a3b58 --- src/audio/sfx_manager.cpp | 44 +++++++++++---------- src/audio/sfx_manager.hpp | 4 +- src/items/powerup.cpp | 83 ++++++++++++++++++++++++++------------- src/items/powerup.hpp | 10 ++--- 4 files changed, 84 insertions(+), 57 deletions(-) diff --git a/src/audio/sfx_manager.cpp b/src/audio/sfx_manager.cpp index 4efd0806e..74cbedc38 100644 --- a/src/audio/sfx_manager.cpp +++ b/src/audio/sfx_manager.cpp @@ -111,27 +111,29 @@ void SFXManager::loadSfx() snprintf(msg, sizeof(msg), "No sfx-config node"); throw std::runtime_error(msg); } - loadSingleSfx(lisp, "ugh", SOUND_UGH ); - loadSingleSfx(lisp, "skid", SOUND_SKID ); - loadSingleSfx(lisp, "winner", SOUND_WINNER ); - loadSingleSfx(lisp, "crash", SOUND_CRASH ); - loadSingleSfx(lisp, "grab", SOUND_GRAB ); - loadSingleSfx(lisp, "shot", SOUND_SHOT ); - loadSingleSfx(lisp, "wee", SOUND_WEE ); - loadSingleSfx(lisp, "explosion", SOUND_EXPLOSION ); - loadSingleSfx(lisp, "bzzt", SOUND_BZZT ); - loadSingleSfx(lisp, "beep", SOUND_BEEP ); - loadSingleSfx(lisp, "back_menu", SOUND_BACK_MENU ); - loadSingleSfx(lisp, "use_anvil", SOUND_USE_ANVIL ); - loadSingleSfx(lisp, "use_parachute", SOUND_USE_PARACHUTE); - loadSingleSfx(lisp, "select_menu", SOUND_SELECT_MENU ); - loadSingleSfx(lisp, "move_menu", SOUND_MOVE_MENU ); - loadSingleSfx(lisp, "full", SOUND_FULL ); - loadSingleSfx(lisp, "prestart", SOUND_PRESTART ); - loadSingleSfx(lisp, "start", SOUND_START ); - loadSingleSfx(lisp, "missile_lock", SOUND_MISSILE_LOCK ); - loadSingleSfx(lisp, "engine_small", SOUND_ENGINE_SMALL ); - loadSingleSfx(lisp, "engine_large", SOUND_ENGINE_LARGE ); + loadSingleSfx(lisp, "ugh", SOUND_UGH ); + loadSingleSfx(lisp, "skid", SOUND_SKID ); + loadSingleSfx(lisp, "bowling_roll", SOUND_BOWLING_ROLL ); + loadSingleSfx(lisp, "bowling_strike",SOUND_BOWLING_STRIKE ); + loadSingleSfx(lisp, "winner", SOUND_WINNER ); + loadSingleSfx(lisp, "crash", SOUND_CRASH ); + loadSingleSfx(lisp, "grab", SOUND_GRAB ); + loadSingleSfx(lisp, "shot", SOUND_SHOT ); + loadSingleSfx(lisp, "wee", SOUND_WEE ); + loadSingleSfx(lisp, "explosion", SOUND_EXPLOSION ); + loadSingleSfx(lisp, "bzzt", SOUND_BZZT ); + loadSingleSfx(lisp, "beep", SOUND_BEEP ); + loadSingleSfx(lisp, "back_menu", SOUND_BACK_MENU ); + loadSingleSfx(lisp, "use_anvil", SOUND_USE_ANVIL ); + loadSingleSfx(lisp, "use_parachute", SOUND_USE_PARACHUTE ); + loadSingleSfx(lisp, "select_menu", SOUND_SELECT_MENU ); + loadSingleSfx(lisp, "move_menu", SOUND_MOVE_MENU ); + loadSingleSfx(lisp, "full", SOUND_FULL ); + loadSingleSfx(lisp, "prestart", SOUND_PRESTART ); + loadSingleSfx(lisp, "start", SOUND_START ); + loadSingleSfx(lisp, "missile_lock", SOUND_MISSILE_LOCK ); + loadSingleSfx(lisp, "engine_small", SOUND_ENGINE_SMALL ); + loadSingleSfx(lisp, "engine_large", SOUND_ENGINE_LARGE ); } // loadSfx //---------------------------------------------------------------------------- void SFXManager::loadSingleSfx(const lisp::Lisp* lisp, diff --git a/src/audio/sfx_manager.hpp b/src/audio/sfx_manager.hpp index cd6671c99..f50f7b4b3 100644 --- a/src/audio/sfx_manager.hpp +++ b/src/audio/sfx_manager.hpp @@ -45,8 +45,8 @@ public: /** The different type of sound effects. */ enum SFXType { - SOUND_UGH, SOUND_SKID, SOUND_WINNER, SOUND_CRASH, SOUND_GRAB, SOUND_SHOT, SOUND_WEE, - SOUND_EXPLOSION, SOUND_BZZT, SOUND_BEEP, SOUND_BACK_MENU, SOUND_USE_ANVIL, + SOUND_UGH, SOUND_SKID, SOUND_BOWLING_ROLL, SOUND_BOWLING_STRIKE, SOUND_WINNER, SOUND_CRASH, SOUND_GRAB, + SOUND_SHOT, SOUND_WEE, SOUND_EXPLOSION, SOUND_BZZT, SOUND_BEEP, SOUND_BACK_MENU, SOUND_USE_ANVIL, SOUND_USE_PARACHUTE, SOUND_SELECT_MENU, SOUND_MOVE_MENU, SOUND_FULL, SOUND_PRESTART, SOUND_START, SOUND_MISSILE_LOCK, SOUND_ENGINE_SMALL, SOUND_ENGINE_LARGE, NUM_SOUNDS diff --git a/src/items/powerup.cpp b/src/items/powerup.cpp index dc5a130b5..6afdff1c7 100644 --- a/src/items/powerup.cpp +++ b/src/items/powerup.cpp @@ -34,9 +34,7 @@ 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); + m_sound_use = NULL; reset(); } // Powerup @@ -45,18 +43,15 @@ Powerup::Powerup(Kart* kart_) */ Powerup::~Powerup() { - sfx_manager->deleteSFX(m_sound_shot); - sfx_manager->deleteSFX(m_sound_use_anvil); - sfx_manager->deleteSFX(m_sound_use_parachute); - + sfx_manager->deleteSFX(m_sound_use); } // ~Powerup //----------------------------------------------------------------------------- void Powerup::reset() { - int type; - RaceManager::getWorld()->getDefaultCollectibles( type, m_number ); - m_type = (PowerupType)type; + int type, number; + RaceManager::getWorld()->getDefaultCollectibles( type, number ); + set( (PowerupType)type, number ); } // reset //----------------------------------------------------------------------------- @@ -69,6 +64,39 @@ void Powerup::set(PowerupType type, int n) } m_type=type; m_number=n; + + if(m_sound_use != NULL) + { + sfx_manager->deleteSFX(m_sound_use); + m_sound_use = NULL; + } + + switch (m_type) + { + case POWERUP_ZIPPER: + break ; + + case POWERUP_BOWLING: + m_sound_use = sfx_manager->newSFX(SFXManager::SOUND_BOWLING_ROLL); + break ; + + case POWERUP_ANVIL: + m_sound_use = sfx_manager->newSFX(SFXManager::SOUND_USE_ANVIL); + break; + + case POWERUP_PARACHUTE: + m_sound_use = sfx_manager->newSFX(SFXManager::SOUND_USE_PARACHUTE); + break; + + case POWERUP_NOTHING: + case POWERUP_CAKE: + case POWERUP_PLUNGER: + case POWERUP_BUBBLEGUM: + default : + m_sound_use = sfx_manager->newSFX(SFXManager::SOUND_SHOT); + break ; + } + } // set //----------------------------------------------------------------------------- @@ -82,6 +110,9 @@ Material *Powerup::getIcon() //----------------------------------------------------------------------------- void Powerup::use() { + // FIXME - for some collectibles, set() is never called + if(m_sound_use == NULL) m_sound_use = sfx_manager->newSFX(SFXManager::SOUND_SHOT); + m_number--; switch (m_type) { @@ -91,15 +122,15 @@ void Powerup::use() case POWERUP_BOWLING: case POWERUP_PLUNGER: - m_sound_shot->position(m_owner->getXYZ()); - m_sound_shot->play(); + m_sound_use->position(m_owner->getXYZ()); + m_sound_use->play(); projectile_manager->newProjectile(m_owner, m_type); break ; case POWERUP_BUBBLEGUM: { - m_sound_shot->position(m_owner->getXYZ()); - m_sound_shot->play(); + m_sound_use->position(m_owner->getXYZ()); + m_sound_use->play(); btVector3 pos = m_owner->getXYZ(); float z_coord = Track::NOHIT; Vec3 normal; @@ -128,8 +159,8 @@ void Powerup::use() kart->attach(ATTACH_ANVIL, stk_config->m_anvil_time); kart->updatedWeight(); kart->adjustSpeed(stk_config->m_anvil_speed_factor*0.5f); - m_sound_use_anvil->position(m_owner->getXYZ()); - m_sound_use_anvil->play(); + m_sound_use->position(m_owner->getXYZ()); + m_sound_use->play(); break; } } @@ -157,8 +188,8 @@ void Powerup::use() if(player_kart) { - m_sound_use_parachute->position(player_kart->getXYZ()); - m_sound_use_parachute->play(); + m_sound_use->position(player_kart->getXYZ()); + m_sound_use->play(); } } break; @@ -186,8 +217,7 @@ void Powerup::hitBonusBox(int n, const Item &item, int add_info) if(network_manager->getMode()==NetworkManager::NW_CLIENT) { m_random.get(100); // keep random numbers in sync - m_type = (PowerupType)add_info; - m_number = 1; + set( (PowerupType)add_info, 1); return; } const int SPECIAL_PROB = (int)(15.0 / ((float)RaceManager::getWorld()->getCurrentNumKarts() / @@ -203,8 +233,7 @@ void Powerup::hitBonusBox(int n, const Item &item, int add_info) if(kart->isEliminated() || kart == m_owner) continue; if(kart->getPosition() == 1 && kart->hasFinishedRace()) { - m_type = POWERUP_PARACHUTE; - m_number = 1; + set(POWERUP_PARACHUTE, 1); if(network_manager->getMode()==NetworkManager::NW_SERVER) { race_state->itemCollected(m_owner->getWorldKartId(), @@ -215,8 +244,8 @@ void Powerup::hitBonusBox(int n, const Item &item, int add_info) } } - m_type = m_random.get(2) == 0 ? POWERUP_ANVIL : POWERUP_PARACHUTE; - m_number = 1; + set( (m_random.get(2) == 0 ? POWERUP_ANVIL : POWERUP_PARACHUTE), 1 ); + if(network_manager->getMode()==NetworkManager::NW_SERVER) { race_state->itemCollected(m_owner->getWorldKartId(), @@ -234,8 +263,7 @@ void Powerup::hitBonusBox(int n, const Item &item, int add_info) { if(m_type==POWERUP_NOTHING) { - m_type = (PowerupType)add_info; - m_number = n; + set( (PowerupType)add_info, n ); } else if((PowerupType)add_info==m_type) { @@ -272,8 +300,7 @@ void Powerup::hitBonusBox(int n, const Item &item, int add_info) if(m_type==POWERUP_NOTHING) { - m_type=newC; - m_number = n; + set( newC, n ); } else if(newC==m_type) { diff --git a/src/items/powerup.hpp b/src/items/powerup.hpp index 86f126303..ebd7b899c 100644 --- a/src/items/powerup.hpp +++ b/src/items/powerup.hpp @@ -33,14 +33,12 @@ class Powerup { private: RandomGenerator m_random; - SFXBase *m_sound_shot; - SFXBase *m_sound_use_anvil; - SFXBase *m_sound_use_parachute; - -protected: - Kart* m_owner; + SFXBase *m_sound_use; PowerupType m_type; int m_number; + +protected: + Kart* m_owner; public: Powerup (Kart* kart_);