Push mainvolume et musicvolume sliders fonctionnels. Bug sfx
This commit is contained in:
parent
67270a0b21
commit
383a19cbd2
@ -5,7 +5,7 @@ Player::Player(const Vector3f& position, float rotX, float rotY) : m_position(po
|
|||||||
m_velocity = Vector3f(0, 0, 0);
|
m_velocity = Vector3f(0, 0, 0);
|
||||||
m_airborne = true;
|
m_airborne = true;
|
||||||
m_hp = 1.0f;
|
m_hp = 1.0f;
|
||||||
m_sensitivity = 0.1f;
|
m_sensitivity = 0.5f;
|
||||||
m_username = "Zelda Bee-Bop56";
|
m_username = "Zelda Bee-Bop56";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,6 +18,9 @@ Audio::Audio(const char * music, const char* menumusic) {
|
|||||||
m_menumusic = m_engine->play2D(menumusic, true, true, true, irrklang::ESM_STREAMING);
|
m_menumusic = m_engine->play2D(menumusic, true, true, true, irrklang::ESM_STREAMING);
|
||||||
m_music->setVolume(.5);
|
m_music->setVolume(.5);
|
||||||
m_menumusic->setVolume(.5);
|
m_menumusic->setVolume(.5);
|
||||||
|
m_mainvolume = 0.5f;
|
||||||
|
m_engine->setSoundVolume(m_mainvolume);
|
||||||
|
m_sfxvolume = 0.5f;
|
||||||
}
|
}
|
||||||
|
|
||||||
Audio::~Audio() {
|
Audio::~Audio() {
|
||||||
@ -99,3 +102,19 @@ void Audio::SetMusicVolume(float volume) {
|
|||||||
m_music->setVolume(volume);
|
m_music->setVolume(volume);
|
||||||
m_menumusic->setVolume(volume);
|
m_menumusic->setVolume(volume);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float Audio::GetMainVolume() const {
|
||||||
|
return m_engine->getSoundVolume();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Audio::SetMainVolume(float volume) {
|
||||||
|
m_engine->setSoundVolume(volume);
|
||||||
|
}
|
||||||
|
|
||||||
|
float Audio::GetSfxVolume() const {
|
||||||
|
return m_sfxvolume;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Audio::SetSfxVolume(float volume) {
|
||||||
|
m_sfxvolume = volume;
|
||||||
|
}
|
||||||
|
@ -16,6 +16,8 @@ class Audio {
|
|||||||
private:
|
private:
|
||||||
irrklang::ISound* m_music;
|
irrklang::ISound* m_music;
|
||||||
irrklang::ISound* m_menumusic;
|
irrklang::ISound* m_menumusic;
|
||||||
|
float m_mainvolume;
|
||||||
|
float m_sfxvolume;
|
||||||
bool m_music_on = true;
|
bool m_music_on = true;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -26,6 +28,7 @@ public:
|
|||||||
|
|
||||||
void Update3DAudio(Vector3f pos, Vector3f dir, Vector3f speed);
|
void Update3DAudio(Vector3f pos, Vector3f dir, Vector3f speed);
|
||||||
|
|
||||||
|
|
||||||
irrklang::ISound* Create3DAudioObj(irrklang::ISound* sound, const char* name, Vector3f pos, Vector3f vel, bool is_looped, float volume);
|
irrklang::ISound* Create3DAudioObj(irrklang::ISound* sound, const char* name, Vector3f pos, Vector3f vel, bool is_looped, float volume);
|
||||||
|
|
||||||
void Render3DAudioObj(irrklang::ISound* sound, Vector3f& pos, Vector3f& vel, float volume);
|
void Render3DAudioObj(irrklang::ISound* sound, Vector3f& pos, Vector3f& vel, float volume);
|
||||||
@ -41,8 +44,14 @@ public:
|
|||||||
|
|
||||||
void PauseEngine();
|
void PauseEngine();
|
||||||
|
|
||||||
|
float GetMainVolume() const;
|
||||||
|
void SetMainVolume(float volume);
|
||||||
|
|
||||||
float GetMusicVolume() const;
|
float GetMusicVolume() const;
|
||||||
void SetMusicVolume(float volume);
|
void SetMusicVolume(float volume);
|
||||||
|
|
||||||
|
float GetSfxVolume() const;
|
||||||
|
void SetSfxVolume(float volume);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // AUDIO_H__
|
#endif // AUDIO_H__
|
||||||
|
@ -45,7 +45,6 @@ void Engine::Init() {
|
|||||||
gluPerspective(45.0f, (float)Width() / (float)Height(), 0.1f, VIEW_DISTANCE);
|
gluPerspective(45.0f, (float)Width() / (float)Height(), 0.1f, VIEW_DISTANCE);
|
||||||
glShadeModel(GL_SMOOTH);
|
glShadeModel(GL_SMOOTH);
|
||||||
|
|
||||||
|
|
||||||
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
|
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
|
||||||
glDisable(GL_BLEND);
|
glDisable(GL_BLEND);
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
@ -241,17 +240,21 @@ void Engine::LoadResource() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Settings
|
// Settings
|
||||||
|
m_mainvolume = m_audio.GetMainVolume();
|
||||||
|
m_options.SetMainVolume(m_mainvolume);
|
||||||
|
|
||||||
m_musicvolume = m_audio.GetMusicVolume();
|
m_musicvolume = m_audio.GetMusicVolume();
|
||||||
m_options.SetMusicVolume(m_musicvolume);
|
m_options.SetMusicVolume(m_musicvolume);
|
||||||
|
|
||||||
|
m_sfxvolume = m_audio.GetSfxVolume();
|
||||||
|
m_options.SetSfxVolume(m_sfxvolume);
|
||||||
|
|
||||||
m_sensitivity = m_player.GetSensitivity();
|
m_sensitivity = m_player.GetSensitivity();
|
||||||
m_options.SetMouseSensitivity(m_sensitivity);
|
m_options.SetMouseSensitivity(m_sensitivity);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Engine::UnloadResource() {}
|
void Engine::UnloadResource() {}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Engine::InstantDamage() {
|
void Engine::InstantDamage() {
|
||||||
m_player.InflictDamage(0.10f);
|
m_player.InflictDamage(0.10f);
|
||||||
m_damage = false;
|
m_damage = false;
|
||||||
@ -1333,11 +1336,11 @@ void Engine::Render(float elapsedTime) {
|
|||||||
if (leftright)
|
if (leftright)
|
||||||
vstep = Vector3f(m_player.GetPosition().x + m_player.GetDirection().z, m_player.GetPosition().y - 1.7f, m_player.GetPosition().z + m_player.GetDirection().x);
|
vstep = Vector3f(m_player.GetPosition().x + m_player.GetDirection().z, m_player.GetPosition().y - 1.7f, m_player.GetPosition().z + m_player.GetDirection().x);
|
||||||
else vstep = Vector3f(m_player.GetPosition().x - m_player.GetDirection().z, m_player.GetPosition().y - 1.7f, m_player.GetPosition().z - m_player.GetDirection().x);
|
else vstep = Vector3f(m_player.GetPosition().x - m_player.GetDirection().z, m_player.GetPosition().y - 1.7f, m_player.GetPosition().z - m_player.GetDirection().x);
|
||||||
m_audio.Create3DAudioObj(step, AUDIO_PATH "step.wav", vstep, m_player.GetVelocity(), false, .8f);
|
m_audio.Create3DAudioObj(step, AUDIO_PATH "step.wav", vstep, m_player.GetVelocity(), false, m_sfxvolume);
|
||||||
leftright = !leftright;
|
leftright = !leftright;
|
||||||
break;
|
break;
|
||||||
case Player::Sound::FALL:
|
case Player::Sound::FALL:
|
||||||
m_audio.Create3DAudioObj(step, AUDIO_PATH "hit.wav", m_player.GetPosition(), m_player.GetVelocity(), false, 1.f);
|
m_audio.Create3DAudioObj(step, AUDIO_PATH "hit.wav", m_player.GetPosition(), m_player.GetVelocity(), false, m_sfxvolume);
|
||||||
break;
|
break;
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
@ -1366,7 +1369,7 @@ void Engine::Render(float elapsedTime) {
|
|||||||
m_bullets[0] = new Bullet(m_player.GetPOV() + m_player.GetDirection(), m_player.GetDirection());
|
m_bullets[0] = new Bullet(m_player.GetPOV() + m_player.GetDirection(), m_player.GetDirection());
|
||||||
}
|
}
|
||||||
bulletTime = BULLET_TIME;
|
bulletTime = BULLET_TIME;
|
||||||
m_audio.Create3DAudioObj(m_powpow, AUDIO_PATH "pow.wav", m_player.GetPOV(), m_player.GetDirection() * 10, false, .5f);
|
m_audio.Create3DAudioObj(m_powpow, AUDIO_PATH "pow.wav", m_player.GetPOV(), m_player.GetDirection() * 10, false, m_sfxvolume);
|
||||||
if (m_flash) { // Coupe le rendering et affiche un frame blanc, pour simuler un flash.
|
if (m_flash) { // Coupe le rendering et affiche un frame blanc, pour simuler un flash.
|
||||||
glClearColor(.8f, .8f, .8f, 1.f);
|
glClearColor(.8f, .8f, .8f, 1.f);
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
||||||
@ -1420,7 +1423,7 @@ void Engine::Render(float elapsedTime) {
|
|||||||
}
|
}
|
||||||
static bool died = false;
|
static bool died = false;
|
||||||
if ((m_player.GetPosition().y < -1.7f || m_player.AmIDead()) && !died) {
|
if ((m_player.GetPosition().y < -1.7f || m_player.AmIDead()) && !died) {
|
||||||
m_audio.Create3DAudioObj(m_scream, AUDIO_PATH "scream.wav", m_player.GetPOV(), m_player.GetVelocity(), false, 1.f);
|
m_audio.Create3DAudioObj(m_scream, AUDIO_PATH "scream.wav", m_player.GetPOV(), m_player.GetVelocity(), false, m_sfxvolume);
|
||||||
died = true;
|
died = true;
|
||||||
}
|
}
|
||||||
if (m_player.GetPosition().y < -21.f || died) {
|
if (m_player.GetPosition().y < -21.f || died) {
|
||||||
@ -1541,7 +1544,7 @@ void Engine::Render(float elapsedTime) {
|
|||||||
RemotePlayer* rt = static_cast<RemotePlayer*>(m_players[out.id]);
|
RemotePlayer* rt = static_cast<RemotePlayer*>(m_players[out.id]);
|
||||||
rt->Feed(out);
|
rt->Feed(out);
|
||||||
if (rt->AmIDead()) {
|
if (rt->AmIDead()) {
|
||||||
m_audio.Create3DAudioObj(m_scream, AUDIO_PATH "scream.wav", m_player.GetPOV(), m_player.GetVelocity(), false, 1.f);
|
m_audio.Create3DAudioObj(m_scream, AUDIO_PATH "scream.wav", m_player.GetPOV(), m_player.GetVelocity(), false, m_sfxvolume);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -1571,7 +1574,7 @@ void Engine::Render(float elapsedTime) {
|
|||||||
m_bullets[0] = bult;
|
m_bullets[0] = bult;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
m_audio.Create3DAudioObj(m_powpow, AUDIO_PATH "pow.wav", bull.pos, bull.dir, false, 1.f);
|
m_audio.Create3DAudioObj(m_powpow, AUDIO_PATH "pow.wav", bull.pos, bull.dir, false, m_sfxvolume);
|
||||||
}
|
}
|
||||||
else SystemNotification("Bullet is kraput.");
|
else SystemNotification("Bullet is kraput.");
|
||||||
break;
|
break;
|
||||||
@ -2146,6 +2149,7 @@ void Engine::MouseMoveEvent(int x, int y) {
|
|||||||
|
|
||||||
if (m_selectedOption == 0 && m_selectedOptAudioMainBar) {
|
if (m_selectedOption == 0 && m_selectedOptAudioMainBar) {
|
||||||
m_mainvolume = normalizedPosition;
|
m_mainvolume = normalizedPosition;
|
||||||
|
m_audio.SetMainVolume(m_mainvolume);
|
||||||
}
|
}
|
||||||
else if (m_selectedOption == 0 && m_selectedOptAudioMusicBar) {
|
else if (m_selectedOption == 0 && m_selectedOptAudioMusicBar) {
|
||||||
m_musicvolume = normalizedPosition;
|
m_musicvolume = normalizedPosition;
|
||||||
@ -2153,6 +2157,7 @@ void Engine::MouseMoveEvent(int x, int y) {
|
|||||||
}
|
}
|
||||||
else if (m_selectedOption == 0 && m_selectedOptAudioSfxBar) {
|
else if (m_selectedOption == 0 && m_selectedOptAudioSfxBar) {
|
||||||
m_sfxvolume = normalizedPosition;
|
m_sfxvolume = normalizedPosition;
|
||||||
|
m_audio.SetSfxVolume(m_sfxvolume);
|
||||||
}
|
}
|
||||||
else if (m_selectedOption == 2 && m_selectedGameplaySensitivityBar) {
|
else if (m_selectedOption == 2 && m_selectedGameplaySensitivityBar) {
|
||||||
m_sensitivity = normalizedPosition;
|
m_sensitivity = normalizedPosition;
|
||||||
@ -2286,8 +2291,9 @@ void Engine::MousePressEvent(const MOUSE_BUTTON& button, int x, int y) {
|
|||||||
|
|
||||||
if (m_selectedOption == 0 && x > leftBar && x < rightBar && y > bottomBarPrincipal && y < topBarPrincipal) {
|
if (m_selectedOption == 0 && x > leftBar && x < rightBar && y > bottomBarPrincipal && y < topBarPrincipal) {
|
||||||
m_audio.playSound(AUDIO_PATH "snap.wav");
|
m_audio.playSound(AUDIO_PATH "snap.wav");
|
||||||
m_mainvolume = normalizedPosition;
|
|
||||||
m_selectedOptAudioMainBar = true;
|
m_selectedOptAudioMainBar = true;
|
||||||
|
m_mainvolume = normalizedPosition;
|
||||||
|
m_audio.SetMainVolume(m_mainvolume);
|
||||||
}
|
}
|
||||||
else if (m_selectedOption == 0 && x > leftBar && x < rightBar && y > bottomBarMusique && y < topBarMusique) {
|
else if (m_selectedOption == 0 && x > leftBar && x < rightBar && y > bottomBarMusique && y < topBarMusique) {
|
||||||
m_audio.playSound(AUDIO_PATH "snap.wav");
|
m_audio.playSound(AUDIO_PATH "snap.wav");
|
||||||
@ -2297,8 +2303,9 @@ void Engine::MousePressEvent(const MOUSE_BUTTON& button, int x, int y) {
|
|||||||
}
|
}
|
||||||
else if (m_selectedOption == 0 && x > leftBar && x < rightBar && y > bottomBarEffets && y < topBarEffets) {
|
else if (m_selectedOption == 0 && x > leftBar && x < rightBar && y > bottomBarEffets && y < topBarEffets) {
|
||||||
m_audio.playSound(AUDIO_PATH "snap.wav");
|
m_audio.playSound(AUDIO_PATH "snap.wav");
|
||||||
m_sfxvolume = normalizedPosition;
|
|
||||||
m_selectedOptAudioSfxBar = true;
|
m_selectedOptAudioSfxBar = true;
|
||||||
|
m_sfxvolume = normalizedPosition;
|
||||||
|
m_audio.SetSfxVolume(m_sfxvolume);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Resolution
|
// Resolution
|
||||||
@ -2340,6 +2347,7 @@ void Engine::MousePressEvent(const MOUSE_BUTTON& button, int x, int y) {
|
|||||||
else if (normalizedPosition > 1.0f) {
|
else if (normalizedPosition > 1.0f) {
|
||||||
normalizedPosition = 1.0f;
|
normalizedPosition = 1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gameplay
|
// Gameplay
|
||||||
if (m_selectedOption == 2 && x > leftBar && x < rightBar && y > bottomBarPrincipal && y < topBarPrincipal) {
|
if (m_selectedOption == 2 && x > leftBar && x < rightBar && y > bottomBarPrincipal && y < topBarPrincipal) {
|
||||||
m_audio.playSound(AUDIO_PATH "snap.wav");
|
m_audio.playSound(AUDIO_PATH "snap.wav");
|
||||||
@ -2388,14 +2396,25 @@ void Engine::MouseReleaseEvent(const MOUSE_BUTTON& button, int x, int y) {
|
|||||||
|
|
||||||
switch (button) {
|
switch (button) {
|
||||||
case MOUSE_BUTTON_LEFT:
|
case MOUSE_BUTTON_LEFT:
|
||||||
if (m_selectedOptAudioMusicBar) {
|
if (m_selectedOption == 0) {
|
||||||
if (normalizedPosition < 0.0f) {
|
if (normalizedPosition < 0.0f) {
|
||||||
normalizedPosition = 0.0f;
|
normalizedPosition = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_selectedOptAudioMainBar) {
|
||||||
|
m_mainvolume = normalizedPosition;
|
||||||
|
m_audio.SetMainVolume(m_mainvolume);
|
||||||
|
}
|
||||||
|
else if (m_selectedOptAudioMusicBar) {
|
||||||
m_musicvolume = normalizedPosition;
|
m_musicvolume = normalizedPosition;
|
||||||
m_audio.SetMusicVolume(m_musicvolume);
|
m_audio.SetMusicVolume(m_musicvolume);
|
||||||
}
|
}
|
||||||
|
else if (m_selectedOptAudioSfxBar) {
|
||||||
|
m_sfxvolume = normalizedPosition;
|
||||||
|
m_audio.SetSfxVolume(m_sfxvolume);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
if (m_selectedGameplaySensitivityBar) {
|
if (m_selectedGameplaySensitivityBar) {
|
||||||
if (normalizedPosition < 0.1f) {
|
if (normalizedPosition < 0.1f) {
|
||||||
normalizedPosition = 0.1f;
|
normalizedPosition = 0.1f;
|
||||||
@ -2404,6 +2423,7 @@ void Engine::MouseReleaseEvent(const MOUSE_BUTTON& button, int x, int y) {
|
|||||||
m_sensitivity = normalizedPosition;
|
m_sensitivity = normalizedPosition;
|
||||||
m_player.SetSensitivity(m_sensitivity);
|
m_player.SetSensitivity(m_sensitivity);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
m_mouseL = false;
|
m_mouseL = false;
|
||||||
m_block = false;
|
m_block = false;
|
||||||
m_selectedOptAudioMainBar = false;
|
m_selectedOptAudioMainBar = false;
|
||||||
|
@ -176,9 +176,9 @@ private:
|
|||||||
int m_nbReductionChunk = 4;
|
int m_nbReductionChunk = 4;
|
||||||
int m_timerReductionChunk = 30;
|
int m_timerReductionChunk = 30;
|
||||||
|
|
||||||
float m_mainvolume = 0.0f;
|
float m_mainvolume;
|
||||||
float m_musicvolume;
|
float m_musicvolume;
|
||||||
float m_sfxvolume = 0.0f;
|
float m_sfxvolume;
|
||||||
float m_sensitivity;
|
float m_sensitivity;
|
||||||
|
|
||||||
int m_selectedOption = 0;
|
int m_selectedOption = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user