More sound tweaks in multiplayer
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@8593 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
a3b3fafe27
commit
41bded8917
@ -25,14 +25,17 @@
|
|||||||
#include "graphics/material.hpp"
|
#include "graphics/material.hpp"
|
||||||
#include "graphics/material_manager.hpp"
|
#include "graphics/material_manager.hpp"
|
||||||
#include "items/projectile_manager.hpp"
|
#include "items/projectile_manager.hpp"
|
||||||
|
#include "race/race_manager.hpp"
|
||||||
#include "utils/vec3.hpp"
|
#include "utils/vec3.hpp"
|
||||||
|
|
||||||
const float burst_time = 0.1f;
|
const float burst_time = 0.1f;
|
||||||
|
|
||||||
Explosion::Explosion(const Vec3& coord, const char* explosion_sound)
|
Explosion::Explosion(const Vec3& coord, const char* explosion_sound, bool player_kart_hit)
|
||||||
{
|
{
|
||||||
m_remaining_time = burst_time; // short emision time, explosion, not constant flame
|
m_remaining_time = burst_time; // short emision time, explosion, not constant flame
|
||||||
m_node = irr_driver->addParticleNode();
|
m_node = irr_driver->addParticleNode();
|
||||||
|
m_player_kart_hit = player_kart_hit;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
m_node->setName("explosion");
|
m_node->setName("explosion");
|
||||||
#endif
|
#endif
|
||||||
@ -89,6 +92,17 @@ Explosion::~Explosion()
|
|||||||
void Explosion::init(const Vec3& coord)
|
void Explosion::init(const Vec3& coord)
|
||||||
{
|
{
|
||||||
m_explode_sound->position(coord);
|
m_explode_sound->position(coord);
|
||||||
|
|
||||||
|
// in multiplayer mode, sounds are NOT positional (because we have multiple listeners)
|
||||||
|
// so the sounds of all AIs are constantly heard. So reduce volume of sounds.
|
||||||
|
if (race_manager->getNumLocalPlayers() > 1)
|
||||||
|
{
|
||||||
|
m_explode_sound->volume(m_player_kart_hit ? 1.0f : 0.5f);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_explode_sound->volume(1.0f);
|
||||||
|
}
|
||||||
m_explode_sound->play();
|
m_explode_sound->play();
|
||||||
} // init
|
} // init
|
||||||
|
|
||||||
|
@ -38,10 +38,11 @@ class Explosion : public NoCopy
|
|||||||
private:
|
private:
|
||||||
SFXBase* m_explode_sound;
|
SFXBase* m_explode_sound;
|
||||||
float m_remaining_time;
|
float m_remaining_time;
|
||||||
|
bool m_player_kart_hit;
|
||||||
scene::IParticleSystemSceneNode *m_node;
|
scene::IParticleSystemSceneNode *m_node;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Explosion(const Vec3& coord, const char* explosion_sound);
|
Explosion(const Vec3& coord, const char* explosion_sound, bool player_hit);
|
||||||
~Explosion();
|
~Explosion();
|
||||||
void init (const Vec3& coord);
|
void init (const Vec3& coord);
|
||||||
void update (float delta_t);
|
void update (float delta_t);
|
||||||
|
@ -126,7 +126,7 @@ void Attachment::hitBanana(Item *item, int new_attachment)
|
|||||||
case ATTACH_BOMB:
|
case ATTACH_BOMB:
|
||||||
{
|
{
|
||||||
add_a_new_item = false;
|
add_a_new_item = false;
|
||||||
projectile_manager->newExplosion(m_kart->getXYZ());
|
projectile_manager->newExplosion(m_kart->getXYZ(), "explosion", m_kart->getController()->isPlayerController());
|
||||||
m_kart->handleExplosion(m_kart->getXYZ(), /*direct_hit*/ true);
|
m_kart->handleExplosion(m_kart->getXYZ(), /*direct_hit*/ true);
|
||||||
clear();
|
clear();
|
||||||
if(new_attachment==-1)
|
if(new_attachment==-1)
|
||||||
@ -235,7 +235,7 @@ void Attachment::update(float dt)
|
|||||||
}
|
}
|
||||||
if(m_time_left<=0.0)
|
if(m_time_left<=0.0)
|
||||||
{
|
{
|
||||||
projectile_manager->newExplosion(m_kart->getXYZ());
|
projectile_manager->newExplosion(m_kart->getXYZ(), "explosion", m_kart->getController()->isPlayerController());
|
||||||
m_kart->handleExplosion(m_kart->getXYZ(),
|
m_kart->handleExplosion(m_kart->getXYZ(),
|
||||||
/*direct_hit*/ true);
|
/*direct_hit*/ true);
|
||||||
}
|
}
|
||||||
|
@ -85,7 +85,7 @@ void ProjectileManager::update(float dt)
|
|||||||
if(! (*p)->hasHit()) { p++; continue; }
|
if(! (*p)->hasHit()) { p++; continue; }
|
||||||
if((*p)->needsExplosion())
|
if((*p)->needsExplosion())
|
||||||
{
|
{
|
||||||
newExplosion((*p)->getXYZ(), (*p)->getExplosionSound() );
|
newExplosion((*p)->getXYZ(), (*p)->getExplosionSound(), false );
|
||||||
}
|
}
|
||||||
Flyable *f=*p;
|
Flyable *f=*p;
|
||||||
Projectiles::iterator pNext=m_active_projectiles.erase(p); // returns the next element
|
Projectiles::iterator pNext=m_active_projectiles.erase(p); // returns the next element
|
||||||
@ -187,9 +187,10 @@ Flyable *ProjectileManager::newProjectile(Kart *kart,
|
|||||||
/** See if there is an old, unused explosion object available. If so,
|
/** See if there is an old, unused explosion object available. If so,
|
||||||
* reuse this object, otherwise create a new one. */
|
* reuse this object, otherwise create a new one. */
|
||||||
Explosion* ProjectileManager::newExplosion(const Vec3& coord,
|
Explosion* ProjectileManager::newExplosion(const Vec3& coord,
|
||||||
const char* explosion_sound)
|
const char* explosion_sound,
|
||||||
|
bool player_kart_hit)
|
||||||
{
|
{
|
||||||
Explosion *e = new Explosion(coord, explosion_sound);
|
Explosion *e = new Explosion(coord, explosion_sound, player_kart_hit);
|
||||||
m_active_explosions.push_back(e);
|
m_active_explosions.push_back(e);
|
||||||
return e;
|
return e;
|
||||||
} // newExplosion
|
} // newExplosion
|
||||||
|
@ -72,7 +72,8 @@ public:
|
|||||||
Flyable* newProjectile (Kart *kart,
|
Flyable* newProjectile (Kart *kart,
|
||||||
PowerupManager::PowerupType type);
|
PowerupManager::PowerupType type);
|
||||||
Explosion* newExplosion (const Vec3& coord,
|
Explosion* newExplosion (const Vec3& coord,
|
||||||
const char* explosion_sound="explosion");
|
const char* explosion_sound="explosion",
|
||||||
|
bool is_player_kart_hit = false);
|
||||||
void Deactivate (Flyable *p) {}
|
void Deactivate (Flyable *p) {}
|
||||||
void removeTextures ();
|
void removeTextures ();
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user