From 6ba316aa2dfbdd319e36584d8087ba575e002896 Mon Sep 17 00:00:00 2001 From: mduval76 <9343789@etu.cegepsth.qc.ca> Date: Wed, 13 Dec 2023 17:15:58 -0500 Subject: [PATCH 01/12] Push mouse sensitivity --- SQCSim-common/player.cpp | 21 +++++++++++----- SQCSim-common/player.h | 9 ++++--- SQCSim2021/engine.cpp | 54 ++++++++++++++++++++++++++-------------- SQCSim2021/engine.h | 2 +- SQCSim2021/settings.cpp | 2 +- 5 files changed, 58 insertions(+), 30 deletions(-) diff --git a/SQCSim-common/player.cpp b/SQCSim-common/player.cpp index 85df138..2052c1c 100644 --- a/SQCSim-common/player.cpp +++ b/SQCSim-common/player.cpp @@ -4,14 +4,15 @@ Player::Player(const Vector3f& position, float rotX, float rotY) : m_position(position), m_rotX(rotX), m_rotY(rotY) { m_velocity = Vector3f(0, 0, 0); m_airborne = true; - m_hp = 1.0f; //TODO: Remettre � 1.0f + m_hp = 1.0f; + m_sensitivity = 0.1f; m_username = "Zelda Bee-Bop56"; } Player::~Player() {} -void Player::TurnLeftRight(float value) { - m_rotY += value; +void Player::TurnLeftRight(float value, float sensitivity) { + m_rotY += value * sensitivity; if (m_rotY > 360) m_rotY = 0; else if (m_rotY < -360) m_rotY = 0; @@ -25,8 +26,8 @@ void Player::TurnLeftRight(float value) { m_direction.Normalize(); } -void Player::TurnTopBottom(float value) { - m_rotX += value; +void Player::TurnTopBottom(float value, float sensitivity) { + m_rotX += value * sensitivity; if (m_rotX > 80) m_rotX = 80; else if (m_rotX < -80) m_rotX = -80; @@ -78,7 +79,7 @@ Vector3f Player::GetInput(bool front, bool back, bool left, bool right, bool jum } if (shoot) // Recoil! - TurnTopBottom(-1); + TurnTopBottom(-1, 1.0f); return delta; } @@ -270,6 +271,14 @@ Vector3f Player::GetDirection() const { return m_direction; } std::string Player::GetUsername() const { return m_username; } +float Player::GetSensitivity() const { + return m_sensitivity; +} + +void Player::SetSensitivity(float sensitivity) { + m_sensitivity = sensitivity; +} + float Player::GetHP() const { return m_hp; } void Player::Teleport(int& x, int& z) { diff --git a/SQCSim-common/player.h b/SQCSim-common/player.h index 6117605..dbd4888 100644 --- a/SQCSim-common/player.h +++ b/SQCSim-common/player.h @@ -16,8 +16,8 @@ public: Player(const Vector3f& position, float rotX = 0, float rotY = 0); ~Player(); - void TurnLeftRight(float value); - void TurnTopBottom(float value); + void TurnLeftRight(float value, float sensitivity); + void TurnTopBottom(float value, float sensitivity); Vector3f GetInput(bool front, bool back, bool left, bool right, bool jump, bool dash, float elapsedTime); Sound ApplyPhysics(Vector3f input, World* world, float elapsedTime); void GetBooster(Booster boosttype); @@ -32,6 +32,8 @@ public: Vector3f GetVelocity() const; Vector3f GetPOV() const; std::string GetUsername() const; + float GetSensitivity() const; + void SetSensitivity(float sensitivity); float GetHP() const; void Teleport(int& x, int& z); @@ -61,6 +63,7 @@ protected: float timeboostspeed; float timeboostdamage; float timeboostinvincible; + float m_sensitivity; float m_hp; @@ -69,8 +72,6 @@ protected: bool boostdamage; bool boostinvincible; - - Vector3f InterpolatePosition(const Vector3f& vec1, const Vector3f& vec2, const Timestamp& tim1, const Timestamp& tim2, const Timestamp& now); }; #endif //_PLAYER_H__ diff --git a/SQCSim2021/engine.cpp b/SQCSim2021/engine.cpp index d27ca25..7c7b66f 100644 --- a/SQCSim2021/engine.cpp +++ b/SQCSim2021/engine.cpp @@ -229,6 +229,8 @@ void Engine::LoadResource() { m_boostinfo[BTYPE_INVINCIBLE] = new BoostInfo(BTYPE_INVINCIBLE, "Inv", u, v, s, 1); m_animeAtlas.TextureIndexToCoord(0, u, v, s, s); + m_sensitivity = m_player.GetSensitivity(); + m_options.SetMouseSensitivity(m_sensitivity); std::cout << " Loading and compiling shaders ..." << std::endl; if (!m_shader01.Load(SHADER_PATH "shader01.vert", SHADER_PATH "shader01.frag", true)) { @@ -1623,8 +1625,8 @@ void Engine::DisplayGameplayMenu(float centerX, float centerY) { float sensibleTop = centerY + Height() * 0.2f; DrawSliderBackground(centerX, centerY, minBar, maxBar, sensibleBottom, sensibleTop); - DrawSlider(centerX, centerY, m_volSensible, minBar, maxBar, sensibleBottom, sensibleTop); - DisplayBarPercentValue(centerX, centerY, percentPosX, sensibleBottom, minBar, maxBar, m_volSensible); + DrawSlider(centerX, centerY, m_sensitivity, minBar, maxBar, sensibleBottom, sensibleTop); + DisplayBarPercentValue(centerX, centerY, percentPosX, sensibleBottom, minBar, maxBar, m_sensitivity); glColor4f(1.0f, 1.0f, 1.0f, 1.0f); } @@ -1644,7 +1646,14 @@ void Engine::DisplayBarPercentValue(float centerX, float centerY, float posX, fl glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE); - float percentage = (value / (maxVal - minVal)) * 100; + if (value < 0.1f) { + value = 0.1f; + } + else if (value > 1.0f) { + value = 1.0f; + } + + float percentage = value * 100; if (percentage < 0.0f) { percentage = 0.0f; @@ -1665,19 +1674,23 @@ void Engine::DisplayBarPercentValue(float centerX, float centerY, float posX, fl } void Engine::DrawSlider(float centerX, float centerY, float value, float minVal, float maxVal, float bottomSideValue, float topSideValue) { - if (value < 0.0f) { - value = 0.0f; + float barLength = maxVal - minVal; + + if (value < 0.1f) { + value = 0.1f; } - else if (value > (maxVal - minVal)) { - value = (maxVal - minVal); + else if (value > 1.0f) { + value = 1.0f; } - if (value >= 0.0f && value <= (maxVal - minVal)) { + float scaledLength = minVal + value * barLength; + + if (value >= 0.0f && value <= 1.0f) { glColor4f(0.0f, 1.0f, 0.0f, 1.0f); glBegin(GL_QUADS); glTexCoord2f(0, 0); glVertex2i(minVal, bottomSideValue); - glTexCoord2f(1, 0); glVertex2i(minVal + value, bottomSideValue); - glTexCoord2f(1, 1); glVertex2i(minVal + value, topSideValue); + glTexCoord2f(1, 0); glVertex2i(scaledLength, bottomSideValue); + glTexCoord2f(1, 1); glVertex2i(scaledLength, topSideValue); glTexCoord2f(0, 1); glVertex2i(minVal, topSideValue); glEnd(); } @@ -2095,11 +2108,10 @@ void Engine::HandlePlayerInput(float elapsedTime) { PrintText(Width() * 0.6f, Height() * 0.4f, ss.str(), 2.0f); } - void Engine::MouseMoveEvent(int x, int y) { if (m_gamestate == GameState::PLAY) { - m_player.TurnLeftRight(x - (Width() / 2)); - m_player.TurnTopBottom(y - (Height() / 2)); + m_player.TurnLeftRight(x - (Width() / 2), m_sensitivity); + m_player.TurnTopBottom(y - (Height() / 2), m_sensitivity); // Centrer la souris seulement si elle n'est pas d�j� centr�e // Il est n�cessaire de faire la v�rification pour �viter de tomber @@ -2117,18 +2129,21 @@ void Engine::MouseMoveEvent(int x, int y) { float centerY = Height() * 0.5f; float leftBar = centerX - Width() * 0.15f; float rightBar = centerX + Width() * 0.3f; + float barLength = rightBar - leftBar; + + float normalizedPosition = (x - leftBar) / barLength; if (m_selectedOption == 0 && m_selectedOptAudioMainBar) { - m_volPrincipal = x - leftBar; + m_volPrincipal = normalizedPosition; } else if (m_selectedOption == 0 && m_selectedOptAudioMusicBar) { - m_volMusique = x - leftBar; + m_volMusique = normalizedPosition; } else if (m_selectedOption == 0 && m_selectedOptAudioSfxBar) { - m_volEffets = x - leftBar; + m_volEffets = normalizedPosition; } else if (m_selectedOption == 2 && m_selectedGameplaySensitivityBar) { - m_volSensible = x - leftBar; + m_sensitivity = normalizedPosition; } } } @@ -2237,6 +2252,7 @@ void Engine::MousePressEvent(const MOUSE_BUTTON& button, int x, int y) { // Audio float leftBar = centerX - Width() * 0.15f; float rightBar = centerX + Width() * 0.3f; + float barLength = rightBar - leftBar; float topBarPrincipal = centerY - Height() * 0.165f; float bottomBarPrincipal = centerY - Height() * 0.2f; @@ -2247,6 +2263,8 @@ void Engine::MousePressEvent(const MOUSE_BUTTON& button, int x, int y) { float topBarEffets = centerY + Height() * 0.085f; float bottomBarEffets = centerY + Height() * 0.05f; + float normalizedPosition = (x - leftBar) / barLength; + if (m_selectedOption == 0 && x > leftBar && x < rightBar && y > bottomBarPrincipal && y < topBarPrincipal) { m_volPrincipal = x - leftBar; m_selectedOptAudioMainBar = true; @@ -2291,7 +2309,7 @@ void Engine::MousePressEvent(const MOUSE_BUTTON& button, int x, int y) { // Gameplay if (m_selectedOption == 2 && x > leftBar && x < rightBar && y > bottomBarPrincipal && y < topBarPrincipal) { - m_volSensible = x - leftBar; + m_sensitivity = normalizedPosition; m_selectedGameplaySensitivityBar = true; } } diff --git a/SQCSim2021/engine.h b/SQCSim2021/engine.h index 1f4bcbc..a791f96 100644 --- a/SQCSim2021/engine.h +++ b/SQCSim2021/engine.h @@ -180,7 +180,7 @@ private: float m_volPrincipal = 0.0f; float m_volMusique = 0.0f; float m_volEffets = 0.0f; - float m_volSensible = 0.0f; + float m_sensitivity; int m_selectedOption = 0; diff --git a/SQCSim2021/settings.cpp b/SQCSim2021/settings.cpp index b84effc..008c4b4 100644 --- a/SQCSim2021/settings.cpp +++ b/SQCSim2021/settings.cpp @@ -9,7 +9,7 @@ Settings::Settings(Audio& audio) m_fullscreen(false), m_brightness(0.5f), m_contrast(0.5f), - m_mouseSensitivity(0.5f) { + m_mouseSensitivity(0.0f) { ApplyResolution(m_resolution); } From 0b4546eee9e30f72444a3e1853666b0c8af6bb5f Mon Sep 17 00:00:00 2001 From: mduval76 <9343789@etu.cegepsth.qc.ca> Date: Wed, 13 Dec 2023 17:50:15 -0500 Subject: [PATCH 02/12] Push sensibilite souris fonctionnelle. --- SQCSim2021/engine.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/SQCSim2021/engine.cpp b/SQCSim2021/engine.cpp index 7c7b66f..3952b77 100644 --- a/SQCSim2021/engine.cpp +++ b/SQCSim2021/engine.cpp @@ -2307,10 +2307,18 @@ void Engine::MousePressEvent(const MOUSE_BUTTON& button, int x, int y) { m_resolution = UHD; } + if (normalizedPosition < 0.1f) { + normalizedPosition = 0.1f; + } + else if (normalizedPosition > 1.0f) { + normalizedPosition = 1.0f; + } // Gameplay if (m_selectedOption == 2 && x > leftBar && x < rightBar && y > bottomBarPrincipal && y < topBarPrincipal) { m_sensitivity = normalizedPosition; + std::cout << "Sensitivity PRESS: " << m_sensitivity << std::endl; m_selectedGameplaySensitivityBar = true; + m_player.SetSensitivity(m_sensitivity); } } else if (m_gamestate == GameState::PAUSE) { @@ -2336,8 +2344,26 @@ void Engine::MousePressEvent(const MOUSE_BUTTON& button, int x, int y) { } void Engine::MouseReleaseEvent(const MOUSE_BUTTON& button, int x, int y) { + float centerX = Width() * 0.5f; + float centerY = Height() * 0.5f; + float leftBar = centerX - Width() * 0.15f; + float rightBar = centerX + Width() * 0.3f; + float barLength = rightBar - leftBar; + switch (button) { case MOUSE_BUTTON_LEFT: + if (m_selectedGameplaySensitivityBar) { + float normalizedPosition = (x - leftBar) / barLength; + if (normalizedPosition < 0.1f) { + normalizedPosition = 0.1f; + } + else if (normalizedPosition > 1.0f) { + normalizedPosition = 1.0f; + } + m_sensitivity = normalizedPosition; + std::cout << "Sensitivity RELEASE: " << m_sensitivity << std::endl; + m_player.SetSensitivity(m_sensitivity); + } m_mouseL = false; m_block = false; m_selectedOptAudioMainBar = false; From 0a0c70883b953c9bc2e171c79534057c2a85add9 Mon Sep 17 00:00:00 2001 From: mduval76 <9343789@etu.cegepsth.qc.ca> Date: Wed, 13 Dec 2023 19:12:22 -0500 Subject: [PATCH 03/12] =?UTF-8?q?Push=20avec=20sensibilit=C3=A9=20souris?= =?UTF-8?q?=20-=20version=20fusionn=C3=A9e=20au=20master=20courant.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SQCSim2021/engine.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/SQCSim2021/engine.cpp b/SQCSim2021/engine.cpp index afb18f7..7cf022a 100644 --- a/SQCSim2021/engine.cpp +++ b/SQCSim2021/engine.cpp @@ -2332,7 +2332,6 @@ void Engine::MousePressEvent(const MOUSE_BUTTON& button, int x, int y) { // Gameplay if (m_selectedOption == 2 && x > leftBar && x < rightBar && y > bottomBarPrincipal && y < topBarPrincipal) { m_audio.playSound(AUDIO_PATH "snap.wav"); - m_volSensible = x - leftBar; m_sensitivity = normalizedPosition; std::cout << "Sensitivity PRESS: " << m_sensitivity << std::endl; m_selectedGameplaySensitivityBar = true; From b101add0e7c7bc55403953eed645b489933097d3 Mon Sep 17 00:00:00 2001 From: mduval76 <9343789@etu.cegepsth.qc.ca> Date: Wed, 13 Dec 2023 19:13:02 -0500 Subject: [PATCH 04/12] Push sans les logs. --- SQCSim2021/engine.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/SQCSim2021/engine.cpp b/SQCSim2021/engine.cpp index 7cf022a..0ce2faf 100644 --- a/SQCSim2021/engine.cpp +++ b/SQCSim2021/engine.cpp @@ -2333,7 +2333,6 @@ void Engine::MousePressEvent(const MOUSE_BUTTON& button, int x, int y) { if (m_selectedOption == 2 && x > leftBar && x < rightBar && y > bottomBarPrincipal && y < topBarPrincipal) { m_audio.playSound(AUDIO_PATH "snap.wav"); m_sensitivity = normalizedPosition; - std::cout << "Sensitivity PRESS: " << m_sensitivity << std::endl; m_selectedGameplaySensitivityBar = true; m_player.SetSensitivity(m_sensitivity); } @@ -2381,7 +2380,6 @@ void Engine::MouseReleaseEvent(const MOUSE_BUTTON& button, int x, int y) { normalizedPosition = 1.0f; } m_sensitivity = normalizedPosition; - std::cout << "Sensitivity RELEASE: " << m_sensitivity << std::endl; m_player.SetSensitivity(m_sensitivity); } m_mouseL = false; From 67270a0b21ce25051ceae8faa4031e068a111bca Mon Sep 17 00:00:00 2001 From: mduval76 <9343789@etu.cegepsth.qc.ca> Date: Wed, 13 Dec 2023 19:59:01 -0500 Subject: [PATCH 05/12] Push options volume musique modifiable fonctionnel --- SQCSim2021/audio.cpp | 5 +++ SQCSim2021/audio.h | 1 + SQCSim2021/engine.cpp | 96 ++++++++++++++++++++++++++----------------- SQCSim2021/engine.h | 6 +-- 4 files changed, 68 insertions(+), 40 deletions(-) diff --git a/SQCSim2021/audio.cpp b/SQCSim2021/audio.cpp index 6df3489..bcd2845 100644 --- a/SQCSim2021/audio.cpp +++ b/SQCSim2021/audio.cpp @@ -94,3 +94,8 @@ void Audio::PauseEngine() { m_engine->setAllSoundsPaused(); } float Audio::GetMusicVolume() const { return m_music->getVolume(); } + +void Audio::SetMusicVolume(float volume) { + m_music->setVolume(volume); + m_menumusic->setVolume(volume); +} diff --git a/SQCSim2021/audio.h b/SQCSim2021/audio.h index 28fbee5..f30e25e 100644 --- a/SQCSim2021/audio.h +++ b/SQCSim2021/audio.h @@ -42,6 +42,7 @@ public: void PauseEngine(); float GetMusicVolume() const; + void SetMusicVolume(float volume); }; #endif // AUDIO_H__ diff --git a/SQCSim2021/engine.cpp b/SQCSim2021/engine.cpp index 0ce2faf..4c302b4 100644 --- a/SQCSim2021/engine.cpp +++ b/SQCSim2021/engine.cpp @@ -167,7 +167,6 @@ void Engine::LoadResource() { TextureAtlas::TextureIndex StillQuarterBackRightShootFire = m_animeAtlas.AddTexture(ANIM_PATH_SSHOOT2 "BlueBackRightShootingRightShoot1.png"); ////23 TextureAtlas::TextureIndex StillBackShootFire = m_animeAtlas.AddTexture(ANIM_PATH_SSHOOT2 "BlueShootingBackRightShoot1.png"); ////24 - //JUMP TextureAtlas::TextureIndex JumpFront = m_animeAtlas.AddTexture(ANIME_PATH_JUMP "BlueFrontJumpRight.png"); ////25 TextureAtlas::TextureIndex JumpQuarterFrontLeft = m_animeAtlas.AddTexture(ANIME_PATH_JUMP "BlueLeftFrontJumpLeft.png"); ////26 @@ -178,7 +177,6 @@ void Engine::LoadResource() { TextureAtlas::TextureIndex JumpQuarterBackRight = m_animeAtlas.AddTexture(ANIME_PATH_JUMP "BlueRightBackJumpRight.png"); ////31 TextureAtlas::TextureIndex JumpBack = m_animeAtlas.AddTexture(ANIME_PATH_JUMP "BlueBackJumpRight.png"); ////32 - //SHOOTINGJUMP SANS TIRER TextureAtlas::TextureIndex JumpFrontShoot = m_animeAtlas.AddTexture(ANIM_PATH_JSHOOT1 "BlueFrontJumpRightShootingRight.png"); ////33 TextureAtlas::TextureIndex JumpQuarterFrontLeftShoot = m_animeAtlas.AddTexture(ANIM_PATH_JSHOOT1 "BlueFrontLeftJumpLeftShootingLeft.png"); ////34 @@ -189,7 +187,6 @@ void Engine::LoadResource() { TextureAtlas::TextureIndex JumpQuarterBackRightShoot = m_animeAtlas.AddTexture(ANIM_PATH_JSHOOT1 "BlueBackRightJumpRightShootingRight.png"); ////39 TextureAtlas::TextureIndex JumpBackShoot = m_animeAtlas.AddTexture(ANIM_PATH_JSHOOT1 "BlueBackJumpRightShootingRight.png"); ////40 - //SHOOTINGJUMP TIRER TextureAtlas::TextureIndex JumpFrontShootFire = m_animeAtlas.AddTexture(ANIM_PATH_JSHOOT2 "BlueFrontJumpRightShootingRightShoot1.png"); ////41 TextureAtlas::TextureIndex JumpQuarterFrontLeftShootFire = m_animeAtlas.AddTexture(ANIM_PATH_JSHOOT2 "BlueFrontLeftJumpLeftShootingLeftShoot1.png"); ////42 @@ -200,8 +197,6 @@ void Engine::LoadResource() { TextureAtlas::TextureIndex JumpQuarterBackRightShootFire = m_animeAtlas.AddTexture(ANIM_PATH_JSHOOT2 "BlueBackRightJumpRightShootingRightShoot1.png"); ////47 TextureAtlas::TextureIndex JumpBackShootFire = m_animeAtlas.AddTexture(ANIM_PATH_JSHOOT2 "BlueBackJumpRightShootingRightShoot1.png"); ////48 - - if (!m_animeAtlas.Generate(TEXTURE_SIZE, false)) { std::cout << " Unable to generate texture atlas ..." << std::endl; abort(); @@ -233,8 +228,6 @@ void Engine::LoadResource() { m_boostinfo[BTYPE_INVINCIBLE] = new BoostInfo(BTYPE_INVINCIBLE, "Inv", u, v, s, 1); m_animeAtlas.TextureIndexToCoord(0, u, v, s, s); - m_sensitivity = m_player.GetSensitivity(); - m_options.SetMouseSensitivity(m_sensitivity); std::cout << " Loading and compiling shaders ..." << std::endl; if (!m_shader01.Load(SHADER_PATH "shader01.vert", SHADER_PATH "shader01.frag", true)) { @@ -246,6 +239,13 @@ void Engine::LoadResource() { std::cout << " Failed to load shader " << std::endl; exit(1); } + + // Settings + m_musicvolume = m_audio.GetMusicVolume(); + m_options.SetMusicVolume(m_musicvolume); + + m_sensitivity = m_player.GetSensitivity(); + m_options.SetMouseSensitivity(m_sensitivity); } void Engine::UnloadResource() {} @@ -1117,8 +1117,8 @@ void Engine::DisplayAudioMenu(float centerX, float centerY) { float principalTop = centerY + Height() * 0.2f; DrawSliderBackground(centerX, centerY, minBar, maxBar, principalBottom, principalTop); - DrawSlider(centerX, centerY, m_volPrincipal, minBar, maxBar, principalBottom, principalTop); - DisplayBarPercentValue(centerX, centerY, percentPosX, principalBottom, minBar, maxBar, m_volPrincipal); + DrawSlider(centerX, centerY, m_mainvolume, minBar, maxBar, principalBottom, principalTop); + DisplayBarPercentValue(centerX, centerY, percentPosX, principalBottom, minBar, maxBar, m_mainvolume); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); @@ -1137,8 +1137,8 @@ void Engine::DisplayAudioMenu(float centerX, float centerY) { float musiqueTop = centerY + Height() * 0.075f; DrawSliderBackground(centerX, centerY, minBar, maxBar, musiqueBottom, musiqueTop); - DrawSlider(centerX, centerY, m_volMusique, minBar, maxBar, musiqueBottom, musiqueTop); - DisplayBarPercentValue(centerX, centerY, percentPosX, musiqueBottom, minBar, maxBar, m_volMusique); + DrawSlider(centerX, centerY, m_musicvolume, minBar, maxBar, musiqueBottom, musiqueTop); + DisplayBarPercentValue(centerX, centerY, percentPosX, musiqueBottom, minBar, maxBar, m_musicvolume); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); @@ -1157,8 +1157,8 @@ void Engine::DisplayAudioMenu(float centerX, float centerY) { float effectsTop = centerY - Height() * 0.05f; DrawSliderBackground(centerX, centerY, minBar, maxBar, effectsBottom, effectsTop); - DrawSlider(centerX, centerY, m_volEffets, minBar, maxBar, effectsBottom, effectsTop); - DisplayBarPercentValue(centerX, centerY, percentPosX, effectsBottom, minBar, maxBar, m_volEffets); + DrawSlider(centerX, centerY, m_sfxvolume, minBar, maxBar, effectsBottom, effectsTop); + DisplayBarPercentValue(centerX, centerY, percentPosX, effectsBottom, minBar, maxBar, m_sfxvolume); glColor4f(1.0f, 1.0f, 1.0f, 1.0f); } @@ -1651,22 +1651,23 @@ void Engine::DisplayBarPercentValue(float centerX, float centerY, float posX, fl glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE); - if (value < 0.1f) { - value = 0.1f; + if (m_selectedOption == 0) { + if (value < 0.0f) { + value = 0.0f; + } } - else if (value > 1.0f) { + else { + if (value < 0.1f) { + value = 0.1f; + } + } + + if (value > 1.0f) { value = 1.0f; } float percentage = value * 100; - if (percentage < 0.0f) { - percentage = 0.0f; - } - else if (percentage > 100.0f) { - percentage = 100.0f; - } - m_textureFont.Bind(); std::ostringstream ss; ss.str(""); @@ -1681,10 +1682,18 @@ void Engine::DisplayBarPercentValue(float centerX, float centerY, float posX, fl void Engine::DrawSlider(float centerX, float centerY, float value, float minVal, float maxVal, float bottomSideValue, float topSideValue) { float barLength = maxVal - minVal; - if (value < 0.1f) { - value = 0.1f; + if (m_selectedOption == 0) { + if (value < 0.0f) { + value = 0.0f; + } } - else if (value > 1.0f) { + else { + if (value < 0.1f) { + value = 0.1f; + } + } + + if (value > 1.0f) { value = 1.0f; } @@ -2136,13 +2145,14 @@ void Engine::MouseMoveEvent(int x, int y) { float normalizedPosition = (x - leftBar) / barLength; if (m_selectedOption == 0 && m_selectedOptAudioMainBar) { - m_volPrincipal = normalizedPosition; + m_mainvolume = normalizedPosition; } else if (m_selectedOption == 0 && m_selectedOptAudioMusicBar) { - m_volMusique = normalizedPosition; + m_musicvolume = normalizedPosition; + m_audio.SetMusicVolume(m_musicvolume); } else if (m_selectedOption == 0 && m_selectedOptAudioSfxBar) { - m_volEffets = normalizedPosition; + m_sfxvolume = normalizedPosition; } else if (m_selectedOption == 2 && m_selectedGameplaySensitivityBar) { m_sensitivity = normalizedPosition; @@ -2276,17 +2286,18 @@ void Engine::MousePressEvent(const MOUSE_BUTTON& button, int x, int y) { if (m_selectedOption == 0 && x > leftBar && x < rightBar && y > bottomBarPrincipal && y < topBarPrincipal) { m_audio.playSound(AUDIO_PATH "snap.wav"); - m_volPrincipal = x - leftBar; + m_mainvolume = normalizedPosition; m_selectedOptAudioMainBar = true; } else if (m_selectedOption == 0 && x > leftBar && x < rightBar && y > bottomBarMusique && y < topBarMusique) { m_audio.playSound(AUDIO_PATH "snap.wav"); - m_volMusique = x - leftBar; m_selectedOptAudioMusicBar = true; + m_musicvolume = normalizedPosition; + m_audio.SetMusicVolume(m_musicvolume); } else if (m_selectedOption == 0 && x > leftBar && x < rightBar && y > bottomBarEffets && y < topBarEffets) { m_audio.playSound(AUDIO_PATH "snap.wav"); - m_volEffets = x - leftBar; + m_sfxvolume = normalizedPosition; m_selectedOptAudioSfxBar = true; } @@ -2332,8 +2343,8 @@ void Engine::MousePressEvent(const MOUSE_BUTTON& button, int x, int y) { // Gameplay if (m_selectedOption == 2 && x > leftBar && x < rightBar && y > bottomBarPrincipal && y < topBarPrincipal) { m_audio.playSound(AUDIO_PATH "snap.wav"); - m_sensitivity = normalizedPosition; m_selectedGameplaySensitivityBar = true; + m_sensitivity = normalizedPosition; m_player.SetSensitivity(m_sensitivity); } } @@ -2369,16 +2380,27 @@ void Engine::MouseReleaseEvent(const MOUSE_BUTTON& button, int x, int y) { float rightBar = centerX + Width() * 0.3f; float barLength = rightBar - leftBar; + float normalizedPosition = (x - leftBar) / barLength; + + if (normalizedPosition > 1.0f) { + normalizedPosition = 1.0f; + } + switch (button) { case MOUSE_BUTTON_LEFT: + if (m_selectedOptAudioMusicBar) { + if (normalizedPosition < 0.0f) { + normalizedPosition = 0.0f; + } + + m_musicvolume = normalizedPosition; + m_audio.SetMusicVolume(m_musicvolume); + } if (m_selectedGameplaySensitivityBar) { - float normalizedPosition = (x - leftBar) / barLength; if (normalizedPosition < 0.1f) { normalizedPosition = 0.1f; } - else if (normalizedPosition > 1.0f) { - normalizedPosition = 1.0f; - } + m_sensitivity = normalizedPosition; m_player.SetSensitivity(m_sensitivity); } diff --git a/SQCSim2021/engine.h b/SQCSim2021/engine.h index 04d21ab..2fa1749 100644 --- a/SQCSim2021/engine.h +++ b/SQCSim2021/engine.h @@ -176,9 +176,9 @@ private: int m_nbReductionChunk = 4; int m_timerReductionChunk = 30; - float m_volPrincipal = 0.0f; - float m_volMusique = 0.0f; - float m_volEffets = 0.0f; + float m_mainvolume = 0.0f; + float m_musicvolume; + float m_sfxvolume = 0.0f; float m_sensitivity; int m_selectedOption = 0; From 383a19cbd259e13a74672dbc27550520b9fc11a5 Mon Sep 17 00:00:00 2001 From: mduval76 <9343789@etu.cegepsth.qc.ca> Date: Thu, 14 Dec 2023 00:08:07 -0500 Subject: [PATCH 06/12] Push mainvolume et musicvolume sliders fonctionnels. Bug sfx --- SQCSim-common/player.cpp | 2 +- SQCSim2021/audio.cpp | 19 +++++++++++++ SQCSim2021/audio.h | 9 ++++++ SQCSim2021/engine.cpp | 60 ++++++++++++++++++++++++++-------------- SQCSim2021/engine.h | 4 +-- 5 files changed, 71 insertions(+), 23 deletions(-) diff --git a/SQCSim-common/player.cpp b/SQCSim-common/player.cpp index 2052c1c..2b2f159 100644 --- a/SQCSim-common/player.cpp +++ b/SQCSim-common/player.cpp @@ -5,7 +5,7 @@ Player::Player(const Vector3f& position, float rotX, float rotY) : m_position(po m_velocity = Vector3f(0, 0, 0); m_airborne = true; m_hp = 1.0f; - m_sensitivity = 0.1f; + m_sensitivity = 0.5f; m_username = "Zelda Bee-Bop56"; } diff --git a/SQCSim2021/audio.cpp b/SQCSim2021/audio.cpp index bcd2845..69537a5 100644 --- a/SQCSim2021/audio.cpp +++ b/SQCSim2021/audio.cpp @@ -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_music->setVolume(.5); m_menumusic->setVolume(.5); + m_mainvolume = 0.5f; + m_engine->setSoundVolume(m_mainvolume); + m_sfxvolume = 0.5f; } Audio::~Audio() { @@ -99,3 +102,19 @@ void Audio::SetMusicVolume(float volume) { m_music->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; +} diff --git a/SQCSim2021/audio.h b/SQCSim2021/audio.h index f30e25e..c0497eb 100644 --- a/SQCSim2021/audio.h +++ b/SQCSim2021/audio.h @@ -16,6 +16,8 @@ class Audio { private: irrklang::ISound* m_music; irrklang::ISound* m_menumusic; + float m_mainvolume; + float m_sfxvolume; bool m_music_on = true; public: @@ -26,6 +28,7 @@ public: 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); void Render3DAudioObj(irrklang::ISound* sound, Vector3f& pos, Vector3f& vel, float volume); @@ -41,8 +44,14 @@ public: void PauseEngine(); + float GetMainVolume() const; + void SetMainVolume(float volume); + float GetMusicVolume() const; void SetMusicVolume(float volume); + + float GetSfxVolume() const; + void SetSfxVolume(float volume); }; #endif // AUDIO_H__ diff --git a/SQCSim2021/engine.cpp b/SQCSim2021/engine.cpp index 4c302b4..4a68b8a 100644 --- a/SQCSim2021/engine.cpp +++ b/SQCSim2021/engine.cpp @@ -45,7 +45,6 @@ void Engine::Init() { gluPerspective(45.0f, (float)Width() / (float)Height(), 0.1f, VIEW_DISTANCE); glShadeModel(GL_SMOOTH); - glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); glDisable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); @@ -241,17 +240,21 @@ void Engine::LoadResource() { } // Settings + m_mainvolume = m_audio.GetMainVolume(); + m_options.SetMainVolume(m_mainvolume); + m_musicvolume = m_audio.GetMusicVolume(); m_options.SetMusicVolume(m_musicvolume); + m_sfxvolume = m_audio.GetSfxVolume(); + m_options.SetSfxVolume(m_sfxvolume); + m_sensitivity = m_player.GetSensitivity(); m_options.SetMouseSensitivity(m_sensitivity); } void Engine::UnloadResource() {} - - void Engine::InstantDamage() { m_player.InflictDamage(0.10f); m_damage = false; @@ -1333,11 +1336,11 @@ void Engine::Render(float elapsedTime) { 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); 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; break; 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; 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()); } 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. glClearColor(.8f, .8f, .8f, 1.f); 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; 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; } if (m_player.GetPosition().y < -21.f || died) { @@ -1541,7 +1544,7 @@ void Engine::Render(float elapsedTime) { RemotePlayer* rt = static_cast(m_players[out.id]); rt->Feed(out); 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; @@ -1571,7 +1574,7 @@ void Engine::Render(float elapsedTime) { m_bullets[0] = bult; 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."); break; @@ -2146,6 +2149,7 @@ void Engine::MouseMoveEvent(int x, int y) { if (m_selectedOption == 0 && m_selectedOptAudioMainBar) { m_mainvolume = normalizedPosition; + m_audio.SetMainVolume(m_mainvolume); } else if (m_selectedOption == 0 && m_selectedOptAudioMusicBar) { m_musicvolume = normalizedPosition; @@ -2153,6 +2157,7 @@ void Engine::MouseMoveEvent(int x, int y) { } else if (m_selectedOption == 0 && m_selectedOptAudioSfxBar) { m_sfxvolume = normalizedPosition; + m_audio.SetSfxVolume(m_sfxvolume); } else if (m_selectedOption == 2 && m_selectedGameplaySensitivityBar) { 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) { m_audio.playSound(AUDIO_PATH "snap.wav"); - m_mainvolume = normalizedPosition; m_selectedOptAudioMainBar = true; + m_mainvolume = normalizedPosition; + m_audio.SetMainVolume(m_mainvolume); } else if (m_selectedOption == 0 && x > leftBar && x < rightBar && y > bottomBarMusique && y < topBarMusique) { 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) { m_audio.playSound(AUDIO_PATH "snap.wav"); - m_sfxvolume = normalizedPosition; m_selectedOptAudioSfxBar = true; + m_sfxvolume = normalizedPosition; + m_audio.SetSfxVolume(m_sfxvolume); } // Resolution @@ -2340,6 +2347,7 @@ void Engine::MousePressEvent(const MOUSE_BUTTON& button, int x, int y) { else if (normalizedPosition > 1.0f) { normalizedPosition = 1.0f; } + // Gameplay if (m_selectedOption == 2 && x > leftBar && x < rightBar && y > bottomBarPrincipal && y < topBarPrincipal) { m_audio.playSound(AUDIO_PATH "snap.wav"); @@ -2388,21 +2396,33 @@ void Engine::MouseReleaseEvent(const MOUSE_BUTTON& button, int x, int y) { switch (button) { case MOUSE_BUTTON_LEFT: - if (m_selectedOptAudioMusicBar) { + if (m_selectedOption == 0) { if (normalizedPosition < 0.0f) { normalizedPosition = 0.0f; } - m_musicvolume = normalizedPosition; - m_audio.SetMusicVolume(m_musicvolume); - } - if (m_selectedGameplaySensitivityBar) { - if (normalizedPosition < 0.1f) { - normalizedPosition = 0.1f; + if (m_selectedOptAudioMainBar) { + m_mainvolume = normalizedPosition; + m_audio.SetMainVolume(m_mainvolume); } + else if (m_selectedOptAudioMusicBar) { + m_musicvolume = normalizedPosition; + m_audio.SetMusicVolume(m_musicvolume); + } + else if (m_selectedOptAudioSfxBar) { + m_sfxvolume = normalizedPosition; + m_audio.SetSfxVolume(m_sfxvolume); + } + } + else { + if (m_selectedGameplaySensitivityBar) { + if (normalizedPosition < 0.1f) { + normalizedPosition = 0.1f; + } - m_sensitivity = normalizedPosition; - m_player.SetSensitivity(m_sensitivity); + m_sensitivity = normalizedPosition; + m_player.SetSensitivity(m_sensitivity); + } } m_mouseL = false; m_block = false; diff --git a/SQCSim2021/engine.h b/SQCSim2021/engine.h index 2fa1749..51666bc 100644 --- a/SQCSim2021/engine.h +++ b/SQCSim2021/engine.h @@ -176,9 +176,9 @@ private: int m_nbReductionChunk = 4; int m_timerReductionChunk = 30; - float m_mainvolume = 0.0f; + float m_mainvolume; float m_musicvolume; - float m_sfxvolume = 0.0f; + float m_sfxvolume; float m_sensitivity; int m_selectedOption = 0; From 1af88ba3e3ff18801d524a11df8bc1c6694a5a61 Mon Sep 17 00:00:00 2001 From: MarcEricMartel Date: Thu, 14 Dec 2023 14:02:29 -0500 Subject: [PATCH 07/12] correction sfx --- SQCSim2021/audio.cpp | 21 ++++++++++++++++++--- SQCSim2021/audio.h | 5 ++++- SQCSim2021/engine.cpp | 35 ++++++++++++++++++----------------- 3 files changed, 40 insertions(+), 21 deletions(-) diff --git a/SQCSim2021/audio.cpp b/SQCSim2021/audio.cpp index 69537a5..97bed1c 100644 --- a/SQCSim2021/audio.cpp +++ b/SQCSim2021/audio.cpp @@ -29,8 +29,11 @@ Audio::~Audio() { if (m_engine) m_engine->drop(); } -void Audio::playSound(const char* sound) { - m_engine->play2D(sound); +void Audio::playSound(const char* name, float volume = 1.) { + irrklang::ISound* sfx = m_engine->play2D(name, false, true); + sfx->setVolume(volume); + sfx->setIsPaused(false); + m_sfxes.push_back(sfx); } void Audio::Update3DAudio(Vector3f pos, Vector3f dir, Vector3f vel) { @@ -40,9 +43,10 @@ void Audio::Update3DAudio(Vector3f pos, Vector3f dir, Vector3f vel) { } irrklang::ISound* Audio::Create3DAudioObj(irrklang::ISound* sound, const char* name, Vector3f pos, Vector3f vel, bool is_looped = false, float volume = 1) { - sound = m_engine->play3D(name, irrklang::vec3df(pos.x, pos.y, pos.z), is_looped, false, true, is_looped? irrklang::ESM_STREAMING: irrklang::ESM_NO_STREAMING, true); + sound = m_engine->play3D(name, irrklang::vec3df(pos.x, pos.y, pos.z), is_looped, true, true, is_looped? irrklang::ESM_STREAMING: irrklang::ESM_NO_STREAMING, true); sound->setVelocity(irrklang::vec3df(vel.x, vel.y, vel.z)); sound->setVolume(volume); + sound->setIsPaused(false); return sound; } @@ -56,6 +60,17 @@ void Audio::Render3DAudioObj(irrklang::ISound* sound, Vector3f& pos, Vector3f& v // m_music = m_engine->play2D(music, false, false, false, irrklang::ESM_STREAMING); //} +void Audio::CleanupSFX() { + while (!m_sfxes.empty()) { + irrklang::ISound* sfx = m_sfxes.back(); + if (sfx->isFinished()) { + sfx->drop(); // drop() fait deja la job du delete sfx. + } + else break; + m_sfxes.pop_back(); + } +} + void Audio::ToggleMusicState(GameState state) { if (m_music_on) { switch (state) { diff --git a/SQCSim2021/audio.h b/SQCSim2021/audio.h index c0497eb..008cd62 100644 --- a/SQCSim2021/audio.h +++ b/SQCSim2021/audio.h @@ -19,6 +19,7 @@ private: float m_mainvolume; float m_sfxvolume; bool m_music_on = true; + std::vector m_sfxes; public: Audio(); @@ -35,9 +36,11 @@ public: //void PlaySong(const char* music); + void CleanupSFX(); + void ToggleMusicState(GameState state); - void playSound(const char* sound); + void playSound(const char* sound, float volume); void SetMusic(bool ison, GameState state); bool GetMusic(); diff --git a/SQCSim2021/engine.cpp b/SQCSim2021/engine.cpp index 4a68b8a..b87cff3 100644 --- a/SQCSim2021/engine.cpp +++ b/SQCSim2021/engine.cpp @@ -1248,6 +1248,7 @@ void Engine::DisplayGraphicsMenu(float centerX, float centerY) { void Engine::Render(float elapsedTime) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); + m_audio.CleanupSFX(); if (m_gamestate == GameState::SPLASH) { if (m_splashTime > 0.0f) { @@ -2206,7 +2207,7 @@ void Engine::MousePressEvent(const MOUSE_BUTTON& button, int x, int y) { float bottomThird = centerY + Height() * 0.198f; if (x > leftButton && x < rightButton && y > bottomFirst && y < topFirst) { - m_audio.playSound(AUDIO_PATH "snap.wav"); + m_audio.playSound(AUDIO_PATH "snap.wav", m_sfxvolume); if (m_selectedPlayOptions) { m_gamestate = GameState::PLAY; m_audio.ToggleMusicState(m_gamestate); @@ -2216,7 +2217,7 @@ void Engine::MousePressEvent(const MOUSE_BUTTON& button, int x, int y) { } } else if (x > leftButton && x < rightButton && y > bottomSecond && y < topSecond) { - m_audio.playSound(AUDIO_PATH "snap.wav"); + m_audio.playSound(AUDIO_PATH "snap.wav", m_sfxvolume); if (m_selectedPlayOptions) { m_gamestate = GameState::LOBBY; m_settingUsername = true; @@ -2226,7 +2227,7 @@ void Engine::MousePressEvent(const MOUSE_BUTTON& button, int x, int y) { } } else if (x > leftButton && x < rightButton && y > bottomThird && y < topThird) { - m_audio.playSound(AUDIO_PATH "snap.wav"); + m_audio.playSound(AUDIO_PATH "snap.wav", m_sfxvolume); if (m_selectedPlayOptions) { m_selectedPlayOptions = false; } @@ -2257,19 +2258,19 @@ void Engine::MousePressEvent(const MOUSE_BUTTON& button, int x, int y) { float bottomBack = centerY + Height() * 0.2f; if (x > leftAudio && x < rightAudio && y > bottomAudio && y < topAudio) { - m_audio.playSound(AUDIO_PATH "snap.wav"); + m_audio.playSound(AUDIO_PATH "snap.wav", m_sfxvolume); m_selectedOption = 0; // Volume } else if (x > leftGraph && x < rightGraph && y > bottomGraph && y < topGraph) { - m_audio.playSound(AUDIO_PATH "snap.wav"); + m_audio.playSound(AUDIO_PATH "snap.wav", m_sfxvolume); m_selectedOption = 1; // Graphics } else if (x > leftGameplay && x < rightGameplay && y > bottomGameplay && y < topGameplay) { - m_audio.playSound(AUDIO_PATH "snap.wav"); + m_audio.playSound(AUDIO_PATH "snap.wav", m_sfxvolume); m_selectedOption = 2; // Gameplay } else if (x > leftBack && x < rightBack && y > bottomBack && y < topBack) { - m_audio.playSound(AUDIO_PATH "snap.wav"); + m_audio.playSound(AUDIO_PATH "snap.wav", m_sfxvolume); m_gamestate = GameState::MAIN_MENU; } @@ -2290,19 +2291,19 @@ void Engine::MousePressEvent(const MOUSE_BUTTON& button, int x, int y) { float normalizedPosition = (x - leftBar) / barLength; 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_sfxvolume); m_selectedOptAudioMainBar = true; m_mainvolume = normalizedPosition; m_audio.SetMainVolume(m_mainvolume); } 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", m_sfxvolume); m_selectedOptAudioMusicBar = true; m_musicvolume = normalizedPosition; m_audio.SetMusicVolume(m_musicvolume); } 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); m_selectedOptAudioSfxBar = true; m_sfxvolume = normalizedPosition; m_audio.SetSfxVolume(m_sfxvolume); @@ -2325,19 +2326,19 @@ void Engine::MousePressEvent(const MOUSE_BUTTON& button, int x, int y) { float bottomChkUHD = centerY; if (m_selectedOption == 1 && leftChk && x < rightChk && y > bottomChkHD && y < topChkHD) { - m_audio.playSound(AUDIO_PATH "snap.wav"); + m_audio.playSound(AUDIO_PATH "snap.wav", m_sfxvolume); m_resolution = HD; } else if (m_selectedOption == 1 && x > leftChk && x < rightChk && y > bottomChkFHD && y < topChkFHD) { - m_audio.playSound(AUDIO_PATH "snap.wav"); + m_audio.playSound(AUDIO_PATH "snap.wav", m_sfxvolume); m_resolution = FHD; } else if (m_selectedOption == 1 && x > leftChk && x < rightChk && y > bottomChkQHD && y < topChkQHD) { - m_audio.playSound(AUDIO_PATH "snap.wav"); + m_audio.playSound(AUDIO_PATH "snap.wav", m_sfxvolume); m_resolution = QHD; } else if (m_selectedOption == 1 && x > leftChk && x < rightChk && y > bottomChkUHD && y < topChkUHD) { - m_audio.playSound(AUDIO_PATH "snap.wav"); + m_audio.playSound(AUDIO_PATH "snap.wav", m_sfxvolume); m_resolution = UHD; } @@ -2350,7 +2351,7 @@ void Engine::MousePressEvent(const MOUSE_BUTTON& button, int x, int y) { // Gameplay 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", m_sfxvolume); m_selectedGameplaySensitivityBar = true; m_sensitivity = normalizedPosition; m_player.SetSensitivity(m_sensitivity); @@ -2368,12 +2369,12 @@ void Engine::MousePressEvent(const MOUSE_BUTTON& button, int x, int y) { float bottomMainMenu = centerY - Height() * 0.4415f; if (x > leftResume && x < rightResume && y > bottomResume && y < topResume) { - m_audio.playSound(AUDIO_PATH "snap.wav"); + m_audio.playSound(AUDIO_PATH "snap.wav", m_sfxvolume); m_gamestate = GameState::PLAY; m_audio.ToggleMusicState(m_gamestate); } else if (x > leftMainMenu && x < rightMainMenu && y > bottomMainMenu && y < topMainMenu) { - m_audio.playSound(AUDIO_PATH "snap.wav"); + m_audio.playSound(AUDIO_PATH "snap.wav", m_sfxvolume); m_gamestate = GameState::MAIN_MENU; m_selectedPlayOptions = false; m_audio.ToggleMusicState(m_gamestate); From e5b0c742dd624153ad53d4b6ae11d68107290804 Mon Sep 17 00:00:00 2001 From: mduval76 <9343789@etu.cegepsth.qc.ca> Date: Thu, 14 Dec 2023 18:25:15 -0500 Subject: [PATCH 08/12] Push back button dans le lobbymenu --- SQCSim-common/player.h | 1 + SQCSim2021/engine.cpp | 19 +++++++++++++++++++ SQCSim2021/engine.h | 1 + 3 files changed, 21 insertions(+) diff --git a/SQCSim-common/player.h b/SQCSim-common/player.h index dbd4888..8a91cb5 100644 --- a/SQCSim-common/player.h +++ b/SQCSim-common/player.h @@ -32,6 +32,7 @@ public: Vector3f GetVelocity() const; Vector3f GetPOV() const; std::string GetUsername() const; + void SetUsername(std::string username); float GetSensitivity() const; void SetSensitivity(float sensitivity); float GetHP() const; diff --git a/SQCSim2021/engine.cpp b/SQCSim2021/engine.cpp index b87cff3..011df6b 100644 --- a/SQCSim2021/engine.cpp +++ b/SQCSim2021/engine.cpp @@ -753,6 +753,15 @@ void Engine::DisplayLobbyMenu(float elapsedTime) { SetServerAddress(elapsedTime); } + glColor4f(1.0f, 1.0f, 1.0f, 1.0f); + m_textureOptBack.Bind(); + glBegin(GL_QUADS); + glTexCoord2f(0, 0); glVertex2i(Width() * 0.675, Height() * 0.15); + glTexCoord2f(1, 0); glVertex2i(Width() * 0.9, Height() * 0.15); + glTexCoord2f(1, 1); glVertex2i(Width() * 0.9, Height() * 0.225); + glTexCoord2f(0, 1); glVertex2i(Width() * 0.675, Height() * 0.225); + glEnd(); + glViewport(viewport[0], viewport[1], viewport[2], viewport[3]); glEnable(GL_DEPTH_TEST); @@ -2380,6 +2389,16 @@ void Engine::MousePressEvent(const MOUSE_BUTTON& button, int x, int y) { m_audio.ToggleMusicState(m_gamestate); } } + else if (m_gamestate == GameState::LOBBY) { + float leftBack = centerX + Width() * 0.178f; + float rightBack = centerX + Width() * 0.397f; + float topBack = centerY + Height() * 0.346f; + float bottomBack = centerY + Height() * 0.275f; + + if (leftBack && x < rightBack && y > bottomBack && y < topBack) { + m_gamestate = GameState::MAIN_MENU; + } + } } void Engine::MouseReleaseEvent(const MOUSE_BUTTON& button, int x, int y) { diff --git a/SQCSim2021/engine.h b/SQCSim2021/engine.h index 51666bc..cd72257 100644 --- a/SQCSim2021/engine.h +++ b/SQCSim2021/engine.h @@ -208,6 +208,7 @@ private: std::string m_currentInputString; std::string m_username; std::string m_serverAddr; + char m_inputChar = 0; bool m_invalidChar = false; bool m_charChanged = false; From 58c06f9f84c8e0b46e599dd648ab3b7d49411c39 Mon Sep 17 00:00:00 2001 From: mduval76 <9343789@etu.cegepsth.qc.ca> Date: Thu, 14 Dec 2023 19:33:25 -0500 Subject: [PATCH 09/12] Push menu Lobby pour single player (entree du username seulement) --- SQCSim-common/player.cpp | 4 ++++ SQCSim2021/engine.cpp | 39 ++++++++++++++++++++++++++++++++------- SQCSim2021/engine.h | 4 ++++ 3 files changed, 40 insertions(+), 7 deletions(-) diff --git a/SQCSim-common/player.cpp b/SQCSim-common/player.cpp index 2b2f159..a0ed584 100644 --- a/SQCSim-common/player.cpp +++ b/SQCSim-common/player.cpp @@ -271,6 +271,10 @@ Vector3f Player::GetDirection() const { return m_direction; } std::string Player::GetUsername() const { return m_username; } +void Player::SetUsername(std::string username) { + m_username = username; +} + float Player::GetSensitivity() const { return m_sensitivity; } diff --git a/SQCSim2021/engine.cpp b/SQCSim2021/engine.cpp index 011df6b..62a439f 100644 --- a/SQCSim2021/engine.cpp +++ b/SQCSim2021/engine.cpp @@ -725,6 +725,7 @@ void Engine::DisplayLobbyMenu(float elapsedTime) { GLint viewport[4]; glGetIntegerv(GL_VIEWPORT, viewport); + glDisable(GL_STENCIL_TEST); glDisable(GL_DEPTH_TEST); glEnable(GL_BLEND); @@ -736,6 +737,7 @@ void Engine::DisplayLobbyMenu(float elapsedTime) { glMatrixMode(GL_MODELVIEW); glPushMatrix(); + glColor4f(1.0f, 1.0f, 1.0f, 1.0f); m_textureLobbyMenu.Bind(); glBegin(GL_QUADS); glTexCoord2f(0, 0); glVertex2i(0, 0); @@ -744,7 +746,6 @@ void Engine::DisplayLobbyMenu(float elapsedTime) { glTexCoord2f(0, 1); glVertex2i(0, Height()); glEnd(); - glColor4f(1.0f, 1.0f, 1.0f, 1.0f); if (m_settingUsername) { SetPlayerUsername(elapsedTime); @@ -764,7 +765,9 @@ void Engine::DisplayLobbyMenu(float elapsedTime) { glViewport(viewport[0], viewport[1], viewport[2], viewport[3]); + glEnable(GL_STENCIL_TEST); glEnable(GL_DEPTH_TEST); + glDisable(GL_BLEND); glMatrixMode(GL_PROJECTION); glPopMatrix(); @@ -773,6 +776,7 @@ void Engine::DisplayLobbyMenu(float elapsedTime) { } void Engine::SetPlayerUsername(float elapsedTime) { + glColor4f(1.0f, 1.0f, 1.0f, 1.0f); m_textureLobbyIdentify.Bind(); glBegin(GL_QUADS); glTexCoord2f(0, 0); glVertex2i(Width() * 0.6, Height() * 0.75); @@ -784,11 +788,10 @@ void Engine::SetPlayerUsername(float elapsedTime) { glBlendFunc(GL_SRC_ALPHA, GL_ONE); HandlePlayerInput(elapsedTime); glDisable(GL_BLEND); - - glColor4f(1.0f, 1.0f, 1.0f, 1.0f); } void Engine::SetServerAddress(float elapsedTime) { + glColor4f(1.0f, 1.0f, 1.0f, 1.0f); m_textureLobbyServer.Bind(); glBegin(GL_QUADS); glTexCoord2f(0, 0); glVertex2i(Width() * 0.6, Height() * 0.75); @@ -801,7 +804,6 @@ void Engine::SetServerAddress(float elapsedTime) { HandlePlayerInput(elapsedTime); glDisable(GL_BLEND); - glColor4f(1.0f, 1.0f, 1.0f, 1.0f); } void Engine::DisplayPauseMenu(float elapsedTime) { @@ -1295,6 +1297,11 @@ void Engine::Render(float elapsedTime) { m_gamestate = GameState::MAIN_MENU; } } + else if (m_singleReady) { + m_gamestate = GameState::PLAY; + m_audio.ToggleMusicState(m_gamestate); + m_startTime = std::chrono::high_resolution_clock::now(); + } return; } @@ -2102,9 +2109,16 @@ void Engine::HandlePlayerInput(float elapsedTime) { m_currentInputString.size() > 1 && m_currentInputString.size() < 26) { m_username = m_currentInputString; + m_player.SetUsername(m_username); m_currentInputString = ""; m_settingUsername = false; - m_settingServer = true; + + if (m_selectedMultiPlayer) { + m_settingServer = true; + } + else if (m_selectedSinglePlayer) { + m_singleReady = true; + } } } else if (m_settingServer) { @@ -2218,8 +2232,12 @@ void Engine::MousePressEvent(const MOUSE_BUTTON& button, int x, int y) { if (x > leftButton && x < rightButton && y > bottomFirst && y < topFirst) { m_audio.playSound(AUDIO_PATH "snap.wav", m_sfxvolume); if (m_selectedPlayOptions) { - m_gamestate = GameState::PLAY; - m_audio.ToggleMusicState(m_gamestate); + m_gamestate = GameState::LOBBY; + m_selectedSinglePlayer = true; + m_selectedMultiPlayer = false; + m_settingUsername = true; + //m_gamestate = GameState::PLAY; + //m_audio.ToggleMusicState(m_gamestate); } else { m_selectedPlayOptions = true; @@ -2229,6 +2247,8 @@ void Engine::MousePressEvent(const MOUSE_BUTTON& button, int x, int y) { m_audio.playSound(AUDIO_PATH "snap.wav", m_sfxvolume); if (m_selectedPlayOptions) { m_gamestate = GameState::LOBBY; + m_selectedMultiPlayer = true; + m_selectedSinglePlayer = false; m_settingUsername = true; } else { @@ -2386,6 +2406,10 @@ void Engine::MousePressEvent(const MOUSE_BUTTON& button, int x, int y) { m_audio.playSound(AUDIO_PATH "snap.wav", m_sfxvolume); m_gamestate = GameState::MAIN_MENU; m_selectedPlayOptions = false; + m_selectedSinglePlayer = false; + m_selectedMultiPlayer = false; + m_singleReady = false; + m_multiReady = false; m_audio.ToggleMusicState(m_gamestate); } } @@ -2396,6 +2420,7 @@ void Engine::MousePressEvent(const MOUSE_BUTTON& button, int x, int y) { float bottomBack = centerY + Height() * 0.275f; if (leftBack && x < rightBack && y > bottomBack && y < topBack) { + m_audio.playSound(AUDIO_PATH "snap.wav", m_sfxvolume); m_gamestate = GameState::MAIN_MENU; } } diff --git a/SQCSim2021/engine.h b/SQCSim2021/engine.h index cd72257..e743d3c 100644 --- a/SQCSim2021/engine.h +++ b/SQCSim2021/engine.h @@ -214,7 +214,11 @@ private: bool m_charChanged = false; bool m_settingUsername = false; bool m_settingServer = false; + bool m_selectedSinglePlayer = false; + bool m_selectedMultiPlayer = false; + bool m_singleReady = false; bool m_multiReady = false; + bool m_key1 = false; bool m_key2 = false; From 82bae1c21a8296e7a6a51987c4da2417021c6b90 Mon Sep 17 00:00:00 2001 From: mduval76 <9343789@etu.cegepsth.qc.ca> Date: Thu, 14 Dec 2023 20:34:59 -0500 Subject: [PATCH 10/12] Push background transparent pour menu options Graphics --- SQCSim2021/engine.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/SQCSim2021/engine.cpp b/SQCSim2021/engine.cpp index 62a439f..c91555d 100644 --- a/SQCSim2021/engine.cpp +++ b/SQCSim2021/engine.cpp @@ -1019,7 +1019,6 @@ void Engine::DisplayOptionsMenu() { glPushMatrix(); m_textureOptionsMenu.Bind(); - glLoadIdentity(); glBegin(GL_QUADS); glTexCoord2f(0, 0); glVertex2i(0, 0); glTexCoord2f(1, 0); glVertex2i(Width(), 0); @@ -1190,10 +1189,10 @@ void Engine::DisplayGraphicsMenu(float centerX, float centerY) { glColor4f(1.0f, 1.0f, 1.0f, 0.5f); glBindTexture(GL_TEXTURE_2D, 0); glBegin(GL_QUADS); - glTexCoord2f(0, 0); glVertex2i(centerX - Width() * 0.16, centerY + Height() * 0.165); - glTexCoord2f(1, 0); glVertex2i(centerX + Width() * 0.1, centerY + Height() * 0.165); - glTexCoord2f(1, 1); glVertex2i(centerX + Width() * 0.1, centerY - Height() * 0.04); - glTexCoord2f(0, 1); glVertex2i(centerX - Width() * 0.16, centerY - Height() * 0.04); + glTexCoord2f(0, 0); glVertex2i(Width() * 0.34, Height() * 0.46); + glTexCoord2f(1, 0); glVertex2i(Width() * 0.6, Height() * 0.46); + glTexCoord2f(1, 1); glVertex2i(Width() * 0.6, Height() * 0.67); + glTexCoord2f(0, 1); glVertex2i(Width() * 0.34, Height() * 0.67); glEnd(); glColor4f(0.0f, 0.0f, 0.0f, 1.0f); @@ -2236,8 +2235,6 @@ void Engine::MousePressEvent(const MOUSE_BUTTON& button, int x, int y) { m_selectedSinglePlayer = true; m_selectedMultiPlayer = false; m_settingUsername = true; - //m_gamestate = GameState::PLAY; - //m_audio.ToggleMusicState(m_gamestate); } else { m_selectedPlayOptions = true; @@ -2354,7 +2351,7 @@ void Engine::MousePressEvent(const MOUSE_BUTTON& button, int x, int y) { float topChkUHD = centerY + Height() * 0.025f; float bottomChkUHD = centerY; - if (m_selectedOption == 1 && leftChk && x < rightChk && y > bottomChkHD && y < topChkHD) { + if (m_selectedOption == 1 && x > leftChk && x < rightChk && y > bottomChkHD && y < topChkHD) { m_audio.playSound(AUDIO_PATH "snap.wav", m_sfxvolume); m_resolution = HD; } From 935a977bdfb6aece131f2d14e52dcd11b0e3ae7d Mon Sep 17 00:00:00 2001 From: mduval76 <9343789@etu.cegepsth.qc.ca> Date: Thu, 14 Dec 2023 21:20:21 -0500 Subject: [PATCH 11/12] Push options resolution fonctionnels. --- SQCSim2021/define.h | 6 ++-- SQCSim2021/engine.cpp | 57 ++++++++++++++++++++++++++++---------- SQCSim2021/engine.h | 1 + SQCSim2021/openglcontext.h | 2 +- 4 files changed, 47 insertions(+), 19 deletions(-) diff --git a/SQCSim2021/define.h b/SQCSim2021/define.h index d0382a7..ca3c4f7 100644 --- a/SQCSim2021/define.h +++ b/SQCSim2021/define.h @@ -25,8 +25,8 @@ #define BULLET_UPDATES_PER_FRAME 20 -#define BASE_WIDTH 640 -#define BASE_HEIGHT 480 +#define BASE_WIDTH 1280 +#define BASE_HEIGHT 720 #define ANIME_PATH_JUMP "./media/textures/AssetOtherPlayer/FinalPNGJumping/" @@ -58,7 +58,7 @@ enum Resolution { HD = 0, // 1280x720 (High Definition) FHD, // 1920x1080 (Full HD) QHD, // 2560x1440 (Quad HD) - UHD // 3840x2160 (Ultra HD) + UHD, // 3840x2160 (Ultra HD) }; #endif // DEFINE_H__ diff --git a/SQCSim2021/engine.cpp b/SQCSim2021/engine.cpp index c91555d..3b1e55e 100644 --- a/SQCSim2021/engine.cpp +++ b/SQCSim2021/engine.cpp @@ -2351,21 +2351,23 @@ void Engine::MousePressEvent(const MOUSE_BUTTON& button, int x, int y) { float topChkUHD = centerY + Height() * 0.025f; float bottomChkUHD = centerY; - if (m_selectedOption == 1 && x > leftChk && x < rightChk && y > bottomChkHD && y < topChkHD) { - m_audio.playSound(AUDIO_PATH "snap.wav", m_sfxvolume); - m_resolution = HD; - } - else if (m_selectedOption == 1 && x > leftChk && x < rightChk && y > bottomChkFHD && y < topChkFHD) { - m_audio.playSound(AUDIO_PATH "snap.wav", m_sfxvolume); - m_resolution = FHD; - } - else if (m_selectedOption == 1 && x > leftChk && x < rightChk && y > bottomChkQHD && y < topChkQHD) { - m_audio.playSound(AUDIO_PATH "snap.wav", m_sfxvolume); - m_resolution = QHD; - } - else if (m_selectedOption == 1 && x > leftChk && x < rightChk && y > bottomChkUHD && y < topChkUHD) { - m_audio.playSound(AUDIO_PATH "snap.wav", m_sfxvolume); - m_resolution = UHD; + if (m_selectedOption == 1) { + if (x > leftChk && x < rightChk && y > bottomChkHD && y < topChkHD) { + m_audio.playSound(AUDIO_PATH "snap.wav", m_sfxvolume); + ChangeResolution(HD); + } + else if (x > leftChk && x < rightChk && y > bottomChkFHD && y < topChkFHD) { + m_audio.playSound(AUDIO_PATH "snap.wav", m_sfxvolume); + ChangeResolution(FHD); + } + else if (x > leftChk && x < rightChk && y > bottomChkQHD && y < topChkQHD) { + m_audio.playSound(AUDIO_PATH "snap.wav", m_sfxvolume); + ChangeResolution(QHD); + } + else if (x > leftChk && x < rightChk && y > bottomChkUHD && y < topChkUHD) { + m_audio.playSound(AUDIO_PATH "snap.wav", m_sfxvolume); + ChangeResolution(UHD); + } } if (normalizedPosition < 0.1f) { @@ -2503,4 +2505,29 @@ bool Engine::LoadTexture(Texture& texture, const std::string& filename, bool use return true; } +void Engine::ChangeResolution(Resolution resolution) { + DeInit(); + + switch (resolution) { + case HD: + OpenglContext::InitWindow(1280, 720); + m_resolution = HD; + break; + case FHD: + OpenglContext::InitWindow(1920, 1080); + m_resolution = FHD; + break; + case QHD: + OpenglContext::InitWindow(2560, 1440); + m_resolution = QHD; + break; + case UHD: + OpenglContext::InitWindow(3840, 2160); + m_resolution = UHD; + break; + } + + Init(); +} + diff --git a/SQCSim2021/engine.h b/SQCSim2021/engine.h index e743d3c..1a1303a 100644 --- a/SQCSim2021/engine.h +++ b/SQCSim2021/engine.h @@ -49,6 +49,7 @@ private: bool StartMultiplayerGame(); bool LoadTexture(Texture& texture, const std::string& filename, bool useMipmaps = true, bool stopOnError = true); + void ChangeResolution(Resolution resolution); void InstantDamage(); void SystemNotification(std::string systemLog); diff --git a/SQCSim2021/openglcontext.h b/SQCSim2021/openglcontext.h index 2718540..3bb711d 100644 --- a/SQCSim2021/openglcontext.h +++ b/SQCSim2021/openglcontext.h @@ -53,9 +53,9 @@ protected: void ShowCrossCursor() const; bool m_istarted = false; + void InitWindow(int width, int height); private: - void InitWindow(int width, int height); MOUSE_BUTTON ConvertMouseButton(sf::Mouse::Button button) const; private: From e4316e7d8d7b02a7a2162d42c51790c5294ff407 Mon Sep 17 00:00:00 2001 From: MarcEricMartel Date: Fri, 15 Dec 2023 06:39:18 -0500 Subject: [PATCH 12/12] =?UTF-8?q?Mis=20le=20son=20qui=20joue=20apr=C3=A8s?= =?UTF-8?q?=20que=20le=20volume=20soit=20chang=C3=A9=20pour=20les=20contr?= =?UTF-8?q?=C3=B4les=20de=20volume?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SQCSim2021/engine.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/SQCSim2021/engine.cpp b/SQCSim2021/engine.cpp index 3b1e55e..b00e88e 100644 --- a/SQCSim2021/engine.cpp +++ b/SQCSim2021/engine.cpp @@ -2317,22 +2317,22 @@ void Engine::MousePressEvent(const MOUSE_BUTTON& button, int x, int y) { float normalizedPosition = (x - leftBar) / barLength; if (m_selectedOption == 0 && x > leftBar && x < rightBar && y > bottomBarPrincipal && y < topBarPrincipal) { - m_audio.playSound(AUDIO_PATH "snap.wav", m_sfxvolume); m_selectedOptAudioMainBar = true; m_mainvolume = normalizedPosition; m_audio.SetMainVolume(m_mainvolume); + m_audio.playSound(AUDIO_PATH "snap.wav", m_sfxvolume); } else if (m_selectedOption == 0 && x > leftBar && x < rightBar && y > bottomBarMusique && y < topBarMusique) { - m_audio.playSound(AUDIO_PATH "snap.wav", m_sfxvolume); m_selectedOptAudioMusicBar = true; m_musicvolume = normalizedPosition; m_audio.SetMusicVolume(m_musicvolume); + m_audio.playSound(AUDIO_PATH "snap.wav", m_sfxvolume); } else if (m_selectedOption == 0 && x > leftBar && x < rightBar && y > bottomBarEffets && y < topBarEffets) { - m_audio.playSound(AUDIO_PATH "snap.wav", m_sfxvolume); m_selectedOptAudioSfxBar = true; m_sfxvolume = normalizedPosition; m_audio.SetSfxVolume(m_sfxvolume); + m_audio.playSound(AUDIO_PATH "snap.wav", m_sfxvolume); } // Resolution