Push options volume musique modifiable fonctionnel
This commit is contained in:
parent
b101add0e7
commit
67270a0b21
@ -94,3 +94,8 @@ void Audio::PauseEngine() { m_engine->setAllSoundsPaused(); }
|
|||||||
float Audio::GetMusicVolume() const {
|
float Audio::GetMusicVolume() const {
|
||||||
return m_music->getVolume();
|
return m_music->getVolume();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Audio::SetMusicVolume(float volume) {
|
||||||
|
m_music->setVolume(volume);
|
||||||
|
m_menumusic->setVolume(volume);
|
||||||
|
}
|
||||||
|
@ -42,6 +42,7 @@ public:
|
|||||||
void PauseEngine();
|
void PauseEngine();
|
||||||
|
|
||||||
float GetMusicVolume() const;
|
float GetMusicVolume() const;
|
||||||
|
void SetMusicVolume(float volume);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // AUDIO_H__
|
#endif // AUDIO_H__
|
||||||
|
@ -167,7 +167,6 @@ void Engine::LoadResource() {
|
|||||||
TextureAtlas::TextureIndex StillQuarterBackRightShootFire = m_animeAtlas.AddTexture(ANIM_PATH_SSHOOT2 "BlueBackRightShootingRightShoot1.png"); ////23
|
TextureAtlas::TextureIndex StillQuarterBackRightShootFire = m_animeAtlas.AddTexture(ANIM_PATH_SSHOOT2 "BlueBackRightShootingRightShoot1.png"); ////23
|
||||||
TextureAtlas::TextureIndex StillBackShootFire = m_animeAtlas.AddTexture(ANIM_PATH_SSHOOT2 "BlueShootingBackRightShoot1.png"); ////24
|
TextureAtlas::TextureIndex StillBackShootFire = m_animeAtlas.AddTexture(ANIM_PATH_SSHOOT2 "BlueShootingBackRightShoot1.png"); ////24
|
||||||
|
|
||||||
|
|
||||||
//JUMP
|
//JUMP
|
||||||
TextureAtlas::TextureIndex JumpFront = m_animeAtlas.AddTexture(ANIME_PATH_JUMP "BlueFrontJumpRight.png"); ////25
|
TextureAtlas::TextureIndex JumpFront = m_animeAtlas.AddTexture(ANIME_PATH_JUMP "BlueFrontJumpRight.png"); ////25
|
||||||
TextureAtlas::TextureIndex JumpQuarterFrontLeft = m_animeAtlas.AddTexture(ANIME_PATH_JUMP "BlueLeftFrontJumpLeft.png"); ////26
|
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 JumpQuarterBackRight = m_animeAtlas.AddTexture(ANIME_PATH_JUMP "BlueRightBackJumpRight.png"); ////31
|
||||||
TextureAtlas::TextureIndex JumpBack = m_animeAtlas.AddTexture(ANIME_PATH_JUMP "BlueBackJumpRight.png"); ////32
|
TextureAtlas::TextureIndex JumpBack = m_animeAtlas.AddTexture(ANIME_PATH_JUMP "BlueBackJumpRight.png"); ////32
|
||||||
|
|
||||||
|
|
||||||
//SHOOTINGJUMP SANS TIRER
|
//SHOOTINGJUMP SANS TIRER
|
||||||
TextureAtlas::TextureIndex JumpFrontShoot = m_animeAtlas.AddTexture(ANIM_PATH_JSHOOT1 "BlueFrontJumpRightShootingRight.png"); ////33
|
TextureAtlas::TextureIndex JumpFrontShoot = m_animeAtlas.AddTexture(ANIM_PATH_JSHOOT1 "BlueFrontJumpRightShootingRight.png"); ////33
|
||||||
TextureAtlas::TextureIndex JumpQuarterFrontLeftShoot = m_animeAtlas.AddTexture(ANIM_PATH_JSHOOT1 "BlueFrontLeftJumpLeftShootingLeft.png"); ////34
|
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 JumpQuarterBackRightShoot = m_animeAtlas.AddTexture(ANIM_PATH_JSHOOT1 "BlueBackRightJumpRightShootingRight.png"); ////39
|
||||||
TextureAtlas::TextureIndex JumpBackShoot = m_animeAtlas.AddTexture(ANIM_PATH_JSHOOT1 "BlueBackJumpRightShootingRight.png"); ////40
|
TextureAtlas::TextureIndex JumpBackShoot = m_animeAtlas.AddTexture(ANIM_PATH_JSHOOT1 "BlueBackJumpRightShootingRight.png"); ////40
|
||||||
|
|
||||||
|
|
||||||
//SHOOTINGJUMP TIRER
|
//SHOOTINGJUMP TIRER
|
||||||
TextureAtlas::TextureIndex JumpFrontShootFire = m_animeAtlas.AddTexture(ANIM_PATH_JSHOOT2 "BlueFrontJumpRightShootingRightShoot1.png"); ////41
|
TextureAtlas::TextureIndex JumpFrontShootFire = m_animeAtlas.AddTexture(ANIM_PATH_JSHOOT2 "BlueFrontJumpRightShootingRightShoot1.png"); ////41
|
||||||
TextureAtlas::TextureIndex JumpQuarterFrontLeftShootFire = m_animeAtlas.AddTexture(ANIM_PATH_JSHOOT2 "BlueFrontLeftJumpLeftShootingLeftShoot1.png"); ////42
|
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 JumpQuarterBackRightShootFire = m_animeAtlas.AddTexture(ANIM_PATH_JSHOOT2 "BlueBackRightJumpRightShootingRightShoot1.png"); ////47
|
||||||
TextureAtlas::TextureIndex JumpBackShootFire = m_animeAtlas.AddTexture(ANIM_PATH_JSHOOT2 "BlueBackJumpRightShootingRightShoot1.png"); ////48
|
TextureAtlas::TextureIndex JumpBackShootFire = m_animeAtlas.AddTexture(ANIM_PATH_JSHOOT2 "BlueBackJumpRightShootingRightShoot1.png"); ////48
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (!m_animeAtlas.Generate(TEXTURE_SIZE, false)) {
|
if (!m_animeAtlas.Generate(TEXTURE_SIZE, false)) {
|
||||||
std::cout << " Unable to generate texture atlas ..." << std::endl;
|
std::cout << " Unable to generate texture atlas ..." << std::endl;
|
||||||
abort();
|
abort();
|
||||||
@ -233,8 +228,6 @@ void Engine::LoadResource() {
|
|||||||
m_boostinfo[BTYPE_INVINCIBLE] = new BoostInfo(BTYPE_INVINCIBLE, "Inv", u, v, s, 1);
|
m_boostinfo[BTYPE_INVINCIBLE] = new BoostInfo(BTYPE_INVINCIBLE, "Inv", u, v, s, 1);
|
||||||
|
|
||||||
m_animeAtlas.TextureIndexToCoord(0, u, v, s, s);
|
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;
|
std::cout << " Loading and compiling shaders ..." << std::endl;
|
||||||
if (!m_shader01.Load(SHADER_PATH "shader01.vert", SHADER_PATH "shader01.frag", true)) {
|
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;
|
std::cout << " Failed to load shader " << std::endl;
|
||||||
exit(1);
|
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() {}
|
void Engine::UnloadResource() {}
|
||||||
@ -1117,8 +1117,8 @@ void Engine::DisplayAudioMenu(float centerX, float centerY) {
|
|||||||
float principalTop = centerY + Height() * 0.2f;
|
float principalTop = centerY + Height() * 0.2f;
|
||||||
|
|
||||||
DrawSliderBackground(centerX, centerY, minBar, maxBar, principalBottom, principalTop);
|
DrawSliderBackground(centerX, centerY, minBar, maxBar, principalBottom, principalTop);
|
||||||
DrawSlider(centerX, centerY, m_volPrincipal, minBar, maxBar, principalBottom, principalTop);
|
DrawSlider(centerX, centerY, m_mainvolume, minBar, maxBar, principalBottom, principalTop);
|
||||||
DisplayBarPercentValue(centerX, centerY, percentPosX, principalBottom, minBar, maxBar, m_volPrincipal);
|
DisplayBarPercentValue(centerX, centerY, percentPosX, principalBottom, minBar, maxBar, m_mainvolume);
|
||||||
|
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
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;
|
float musiqueTop = centerY + Height() * 0.075f;
|
||||||
|
|
||||||
DrawSliderBackground(centerX, centerY, minBar, maxBar, musiqueBottom, musiqueTop);
|
DrawSliderBackground(centerX, centerY, minBar, maxBar, musiqueBottom, musiqueTop);
|
||||||
DrawSlider(centerX, centerY, m_volMusique, minBar, maxBar, musiqueBottom, musiqueTop);
|
DrawSlider(centerX, centerY, m_musicvolume, minBar, maxBar, musiqueBottom, musiqueTop);
|
||||||
DisplayBarPercentValue(centerX, centerY, percentPosX, musiqueBottom, minBar, maxBar, m_volMusique);
|
DisplayBarPercentValue(centerX, centerY, percentPosX, musiqueBottom, minBar, maxBar, m_musicvolume);
|
||||||
|
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
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;
|
float effectsTop = centerY - Height() * 0.05f;
|
||||||
|
|
||||||
DrawSliderBackground(centerX, centerY, minBar, maxBar, effectsBottom, effectsTop);
|
DrawSliderBackground(centerX, centerY, minBar, maxBar, effectsBottom, effectsTop);
|
||||||
DrawSlider(centerX, centerY, m_volEffets, minBar, maxBar, effectsBottom, effectsTop);
|
DrawSlider(centerX, centerY, m_sfxvolume, minBar, maxBar, effectsBottom, effectsTop);
|
||||||
DisplayBarPercentValue(centerX, centerY, percentPosX, effectsBottom, minBar, maxBar, m_volEffets);
|
DisplayBarPercentValue(centerX, centerY, percentPosX, effectsBottom, minBar, maxBar, m_sfxvolume);
|
||||||
|
|
||||||
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
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);
|
glEnable(GL_BLEND);
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
|
||||||
|
|
||||||
if (value < 0.1f) {
|
if (m_selectedOption == 0) {
|
||||||
value = 0.1f;
|
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;
|
value = 1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
float percentage = value * 100;
|
float percentage = value * 100;
|
||||||
|
|
||||||
if (percentage < 0.0f) {
|
|
||||||
percentage = 0.0f;
|
|
||||||
}
|
|
||||||
else if (percentage > 100.0f) {
|
|
||||||
percentage = 100.0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_textureFont.Bind();
|
m_textureFont.Bind();
|
||||||
std::ostringstream ss;
|
std::ostringstream ss;
|
||||||
ss.str("");
|
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) {
|
void Engine::DrawSlider(float centerX, float centerY, float value, float minVal, float maxVal, float bottomSideValue, float topSideValue) {
|
||||||
float barLength = maxVal - minVal;
|
float barLength = maxVal - minVal;
|
||||||
|
|
||||||
if (value < 0.1f) {
|
if (m_selectedOption == 0) {
|
||||||
value = 0.1f;
|
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;
|
value = 1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2136,13 +2145,14 @@ void Engine::MouseMoveEvent(int x, int y) {
|
|||||||
float normalizedPosition = (x - leftBar) / barLength;
|
float normalizedPosition = (x - leftBar) / barLength;
|
||||||
|
|
||||||
if (m_selectedOption == 0 && m_selectedOptAudioMainBar) {
|
if (m_selectedOption == 0 && m_selectedOptAudioMainBar) {
|
||||||
m_volPrincipal = normalizedPosition;
|
m_mainvolume = normalizedPosition;
|
||||||
}
|
}
|
||||||
else if (m_selectedOption == 0 && m_selectedOptAudioMusicBar) {
|
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) {
|
else if (m_selectedOption == 0 && m_selectedOptAudioSfxBar) {
|
||||||
m_volEffets = normalizedPosition;
|
m_sfxvolume = normalizedPosition;
|
||||||
}
|
}
|
||||||
else if (m_selectedOption == 2 && m_selectedGameplaySensitivityBar) {
|
else if (m_selectedOption == 2 && m_selectedGameplaySensitivityBar) {
|
||||||
m_sensitivity = normalizedPosition;
|
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) {
|
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_volPrincipal = x - leftBar;
|
m_mainvolume = normalizedPosition;
|
||||||
m_selectedOptAudioMainBar = true;
|
m_selectedOptAudioMainBar = true;
|
||||||
}
|
}
|
||||||
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");
|
||||||
m_volMusique = x - leftBar;
|
|
||||||
m_selectedOptAudioMusicBar = true;
|
m_selectedOptAudioMusicBar = true;
|
||||||
|
m_musicvolume = normalizedPosition;
|
||||||
|
m_audio.SetMusicVolume(m_musicvolume);
|
||||||
}
|
}
|
||||||
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_volEffets = x - leftBar;
|
m_sfxvolume = normalizedPosition;
|
||||||
m_selectedOptAudioSfxBar = true;
|
m_selectedOptAudioSfxBar = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2332,8 +2343,8 @@ void Engine::MousePressEvent(const MOUSE_BUTTON& button, int x, int y) {
|
|||||||
// 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");
|
||||||
m_sensitivity = normalizedPosition;
|
|
||||||
m_selectedGameplaySensitivityBar = true;
|
m_selectedGameplaySensitivityBar = true;
|
||||||
|
m_sensitivity = normalizedPosition;
|
||||||
m_player.SetSensitivity(m_sensitivity);
|
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 rightBar = centerX + Width() * 0.3f;
|
||||||
float barLength = rightBar - leftBar;
|
float barLength = rightBar - leftBar;
|
||||||
|
|
||||||
|
float normalizedPosition = (x - leftBar) / barLength;
|
||||||
|
|
||||||
|
if (normalizedPosition > 1.0f) {
|
||||||
|
normalizedPosition = 1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
switch (button) {
|
switch (button) {
|
||||||
case MOUSE_BUTTON_LEFT:
|
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) {
|
if (m_selectedGameplaySensitivityBar) {
|
||||||
float normalizedPosition = (x - leftBar) / barLength;
|
|
||||||
if (normalizedPosition < 0.1f) {
|
if (normalizedPosition < 0.1f) {
|
||||||
normalizedPosition = 0.1f;
|
normalizedPosition = 0.1f;
|
||||||
}
|
}
|
||||||
else if (normalizedPosition > 1.0f) {
|
|
||||||
normalizedPosition = 1.0f;
|
|
||||||
}
|
|
||||||
m_sensitivity = normalizedPosition;
|
m_sensitivity = normalizedPosition;
|
||||||
m_player.SetSensitivity(m_sensitivity);
|
m_player.SetSensitivity(m_sensitivity);
|
||||||
}
|
}
|
||||||
|
@ -176,9 +176,9 @@ private:
|
|||||||
int m_nbReductionChunk = 4;
|
int m_nbReductionChunk = 4;
|
||||||
int m_timerReductionChunk = 30;
|
int m_timerReductionChunk = 30;
|
||||||
|
|
||||||
float m_volPrincipal = 0.0f;
|
float m_mainvolume = 0.0f;
|
||||||
float m_volMusique = 0.0f;
|
float m_musicvolume;
|
||||||
float m_volEffets = 0.0f;
|
float m_sfxvolume = 0.0f;
|
||||||
float m_sensitivity;
|
float m_sensitivity;
|
||||||
|
|
||||||
int m_selectedOption = 0;
|
int m_selectedOption = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user