Moved skid sound from player_kart to kart. Fixed lingering explosion bug. Increased music buffer size to 1 full second of audio.

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@2426 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
stevo14
2008-11-08 11:30:50 +00:00
parent 544424ee93
commit 44f0bc4009
7 changed files with 41 additions and 26 deletions

View File

@@ -78,7 +78,7 @@ private:
ALenum nb_channels;
bool m_pausedMusic;
static const int m_buffer_size = 4096*8;
static const int m_buffer_size = 11025*4;//one full second of audio at 44100 samples per second
};
#endif // HEADER_MUSICOGG_H

View File

@@ -53,23 +53,32 @@ void Explosion::init(const Vec3& coord)
setTransform(&c);
m_step = -1;
scene->add(this);
m_has_ended = false;
}
//-----------------------------------------------------------------------------
void Explosion::update(float dt)
{
//fprintf(stderr, "Explosion: update: ");
if(++m_step >= m_seq->getNumKids())
{
//be sure that the sound is not prematurely stopped
if(m_explode_sound->getStatus() != SFXManager::SFX_PLAYING)
{
//fprintf(stderr, "Sound finished. Removing.\n");
scene->remove((ssgTransform*)this);
projectile_manager->FinishedExplosion();
m_has_ended = true;
return;
}
else
{
//fprintf(stderr, "Waiting for sound to finish.\n");
}
}
else
{
//fprintf(stderr, "Step.\n");
m_seq->selectStep(m_step);
}
}

View File

@@ -28,7 +28,9 @@ class SFXBase;
class Explosion : public ssgTransform
{
private:
SFXBase* m_explode_sound;
SFXBase* m_explode_sound;
bool m_has_ended;
public:
int m_step ;
ssgSelector *m_seq ;
@@ -37,8 +39,8 @@ public:
~Explosion();
void init (const Vec3& coord);
void update (float delta_t);
int inUse () {return (m_step >= 0); }
bool hasEnded () {return m_step >= m_seq->getNumKids(); }
int inUse () { return (m_step >= 0); }
bool hasEnded () { return m_has_ended; }
} ;

View File

@@ -102,9 +102,10 @@ Kart::Kart (const std::string& kart_name, int position,
m_rescue = false;
m_wheel_rotation = 0;
m_engine_sound = sfx_manager->newSFX(SFXManager::SOUND_ENGINE);
m_beep_sound = sfx_manager->newSFX(SFXManager::SOUND_BEEP);
m_crash_sound = sfx_manager->newSFX(SFXManager::SOUND_CRASH);
m_engine_sound = sfx_manager->newSFX(SFXManager::SOUND_ENGINE );
m_beep_sound = sfx_manager->newSFX(SFXManager::SOUND_BEEP );
m_crash_sound = sfx_manager->newSFX(SFXManager::SOUND_CRASH );
m_skid_sound = sfx_manager->newSFX(SFXManager::SOUND_SKID );
if(!m_engine_sound)
{
@@ -238,10 +239,10 @@ Kart::~Kart()
{
m_engine_sound->stop();
}
sfx_manager->deleteSFX(m_engine_sound);
sfx_manager->deleteSFX(m_beep_sound);
sfx_manager->deleteSFX(m_crash_sound);
sfx_manager->deleteSFX(m_engine_sound );
sfx_manager->deleteSFX(m_beep_sound );
sfx_manager->deleteSFX(m_crash_sound );
sfx_manager->deleteSFX(m_skid_sound );
if(m_smokepuff) delete m_smokepuff;
if(m_smoke_system != NULL) delete m_smoke_system;
@@ -374,6 +375,7 @@ void Kart::collectedItem(const Item &item, int add_info)
case ITEM_BUBBLEGUM:
// slow down
m_body->setLinearVelocity(m_body->getLinearVelocity()*0.3f);
m_skid_sound->play();
break;
default : break;
} // switch TYPE
@@ -523,9 +525,10 @@ void Kart::update(float dt)
Moveable::update(dt);
m_engine_sound->position(getXYZ());
m_beep_sound->position(getXYZ());
m_crash_sound->position(getXYZ());
m_engine_sound->position ( getXYZ() );
m_beep_sound->position ( getXYZ() );
m_crash_sound->position ( getXYZ() );
m_skid_sound->position ( getXYZ() );
// Check if a kart is (nearly) upside down and not moving much --> automatic rescue
if((fabs(getHPR().getRoll())>60 && fabs(getSpeed())<3.0f) )

View File

@@ -98,6 +98,7 @@ private:
SFXBase *m_engine_sound;
SFXBase *m_beep_sound;
SFXBase *m_crash_sound;
SFXBase *m_skid_sound;
protected:
float m_rescue_pitch, m_rescue_roll;

View File

@@ -46,7 +46,6 @@ PlayerKart::PlayerKart(const std::string& kart_name, int position, Player *playe
m_bzzt_sound = sfx_manager->newSFX(SFXManager::SOUND_BZZT );
m_wee_sound = sfx_manager->newSFX(SFXManager::SOUND_WEE );
m_ugh_sound = sfx_manager->newSFX(SFXManager::SOUND_UGH );
m_skid_sound = sfx_manager->newSFX(SFXManager::SOUND_SKID );
m_grab_sound = sfx_manager->newSFX(SFXManager::SOUND_GRAB );
m_full_sound = sfx_manager->newSFX(SFXManager::SOUND_FULL );
@@ -59,7 +58,6 @@ PlayerKart::~PlayerKart()
sfx_manager->deleteSFX(m_bzzt_sound);
sfx_manager->deleteSFX(m_wee_sound );
sfx_manager->deleteSFX(m_ugh_sound );
sfx_manager->deleteSFX(m_skid_sound);
sfx_manager->deleteSFX(m_grab_sound);
sfx_manager->deleteSFX(m_full_sound);
} // ~PlayerKart
@@ -303,16 +301,19 @@ void PlayerKart::collectedItem(const Item &item, int add_info)
}
else
{
if(item.getType() == ITEM_BANANA || item.getType() == ITEM_BUBBLEGUM)
m_ugh_sound->play();
else
m_grab_sound->play();
if(item.getType() == ITEM_BUBBLEGUM)
switch(item.getType())
{
m_skid_sound->position( getXYZ() );
m_skid_sound->play();
}
case ITEM_BANANA:
m_ugh_sound->play();
break;
case ITEM_BUBBLEGUM:
//The skid sound is played by the kart class. Do nothing here.
//See Kart::collectedItem()
break;
default:
m_grab_sound->play();
break;
}
}
} // collectedItem

View File

@@ -43,7 +43,6 @@ private:
SFXBase *m_bzzt_sound;
SFXBase *m_wee_sound;
SFXBase *m_ugh_sound;
SFXBase *m_skid_sound;
SFXBase *m_grab_sound;
SFXBase *m_full_sound;