diff --git a/SQCSim2021/engine.cpp b/SQCSim2021/engine.cpp index c90147c..a409b9a 100644 --- a/SQCSim2021/engine.cpp +++ b/SQCSim2021/engine.cpp @@ -408,33 +408,6 @@ void Engine::DrawMenu() glVertex2i(0, 200); glEnd(); - /*WireFrameTexture.Bind(); - glTranslated(0, 300, 0); - glBegin(GL_QUADS); - glTexCoord2f(0, 0); - glVertex2i(0, 125); - glTexCoord2f(1, 0); - glVertex2i(sButton, 125); - glTexCoord2f(1, 1); - glVertex2i(sButton, 200); - glTexCoord2f(0, 1); - glVertex2i(0, 200); - glEnd();*/ - - /*OnOffBtnTexture.Bind(); - glTranslated(200, 0, 0); - glBegin(GL_QUADS); - glTexCoord2f(0, 0); - glVertex2i(0, 125); - glTexCoord2f(1, 0); - glVertex2i(sButton, 125); - glTexCoord2f(1, 1); - glVertex2i(sButton, 200); - glTexCoord2f(0, 1); - glVertex2i(0, 200); - glEnd(); - glTranslated(-400, -300, 0);*/ - MusicTexture.Bind(); glTranslated(200, 200, 0); glBegin(GL_QUADS); @@ -600,6 +573,9 @@ void Engine::DrawOption() void Engine::DisplayAudioMenu(float centerX, float centerY) { glColor4f(1.0f, 0.5f, 0.0f, 1.0f); + + float minBar = centerX - Width() * 0.15; + float maxBar = centerX + Width() * 0.3; m_texturePrincipal.Bind(); glBegin(GL_QUADS); glTexCoord2f(0, 0); glVertex2i(centerX - Width() * 0.15, centerY + Height() * 0.215); @@ -611,12 +587,20 @@ void Engine::DisplayAudioMenu(float centerX, float centerY) { glColor4f(0.0f, 0.0f, 0.0f, 1.0f); glBindTexture(GL_TEXTURE_2D, 0); glBegin(GL_QUADS); - glTexCoord2f(0, 0); glVertex2i(centerX - Width() * 0.15, centerY + Height() * 0.165); - glTexCoord2f(1, 0); glVertex2i(centerX + Width() * 0.3, centerY + Height() * 0.165); - glTexCoord2f(1, 1); glVertex2i(centerX + Width() * 0.3, centerY + Height() * 0.2); - glTexCoord2f(0, 1); glVertex2i(centerX - Width() * 0.15, centerY + Height() * 0.2); + glTexCoord2f(0, 0); glVertex2i(minBar, centerY + Height() * 0.165); + glTexCoord2f(1, 0); glVertex2i(maxBar, centerY + Height() * 0.165); + glTexCoord2f(1, 1); glVertex2i(maxBar, centerY + Height() * 0.2); + glTexCoord2f(0, 1); glVertex2i(minBar, centerY + Height() * 0.2); glEnd(); + glColor4f(0.0f, 1.0f, 0.0f, 1.0f); + glBegin(GL_QUADS); + glTexCoord2f(0, 0); glVertex2i(minBar, centerY + Height() * 0.165); + glTexCoord2f(1, 0); glVertex2i(minBar + m_volMain, centerY + Height() * 0.165); + glTexCoord2f(1, 1); glVertex2i(minBar + m_volMain, centerY + Height() * 0.2); + glTexCoord2f(0, 1); glVertex2i(minBar, centerY + Height() * 0.2); + glEnd(); + glColor4f(1.0f, 0.5f, 0.0f, 1.0f); m_textureMusique.Bind(); glBegin(GL_QUADS); @@ -629,12 +613,20 @@ void Engine::DisplayAudioMenu(float centerX, float centerY) { glColor4f(0.0f, 0.0f, 0.0f, 1.0f); glBindTexture(GL_TEXTURE_2D, 0); glBegin(GL_QUADS); - glTexCoord2f(0, 0); glVertex2i(centerX - Width() * 0.15, centerY + Height() * 0.04); - glTexCoord2f(1, 0); glVertex2i(centerX + Width() * 0.3, centerY + Height() * 0.04); - glTexCoord2f(1, 1); glVertex2i(centerX + Width() * 0.3, centerY + Height() * 0.075); - glTexCoord2f(0, 1); glVertex2i(centerX - Width() * 0.15, centerY + Height() * 0.075); + glTexCoord2f(0, 0); glVertex2i(minBar, centerY + Height() * 0.04); + glTexCoord2f(1, 0); glVertex2i(maxBar, centerY + Height() * 0.04); + glTexCoord2f(1, 1); glVertex2i(maxBar, centerY + Height() * 0.075); + glTexCoord2f(0, 1); glVertex2i(minBar, centerY + Height() * 0.075); glEnd(); + glColor4f(0.0f, 1.0f, 0.0f, 1.0f); + glBegin(GL_QUADS); + glTexCoord2f(0, 0); glVertex2i(minBar, centerY + Height() * 0.04); + glTexCoord2f(1, 0); glVertex2i(minBar + m_volMusic, centerY + Height() * 0.04); + glTexCoord2f(1, 1); glVertex2i(minBar + m_volMusic, centerY + Height() * 0.075); + glTexCoord2f(0, 1); glVertex2i(minBar, centerY + Height() * 0.075); + glEnd(); + glColor4f(1.0f, 0.5f, 0.0f, 1.0f); m_textureEffets.Bind(); glBegin(GL_QUADS); @@ -647,12 +639,20 @@ void Engine::DisplayAudioMenu(float centerX, float centerY) { glColor4f(0.0f, 0.0f, 0.0f, 1.0f); glBindTexture(GL_TEXTURE_2D, 0); glBegin(GL_QUADS); - glTexCoord2f(0, 0); glVertex2i(centerX - Width() * 0.15, centerY - Height() * 0.085); - glTexCoord2f(1, 0); glVertex2i(centerX + Width() * 0.3, centerY - Height() * 0.085); - glTexCoord2f(1, 1); glVertex2i(centerX + Width() * 0.3, centerY - Height() * 0.05); - glTexCoord2f(0, 1); glVertex2i(centerX - Width() * 0.15, centerY - Height() * 0.05); + glTexCoord2f(0, 0); glVertex2i(minBar, centerY - Height() * 0.085); + glTexCoord2f(1, 0); glVertex2i(maxBar, centerY - Height() * 0.085); + glTexCoord2f(1, 1); glVertex2i(maxBar, centerY - Height() * 0.05); + glTexCoord2f(0, 1); glVertex2i(minBar, centerY - Height() * 0.05); glEnd(); + glColor4f(0.0f, 1.0f, 0.0f, 1.0f); + glBegin(GL_QUADS); + glTexCoord2f(0, 0); glVertex2i(minBar, centerY - Height() * 0.085); + glTexCoord2f(1, 0); glVertex2i(minBar + m_volEffects, centerY - Height() * 0.085); + glTexCoord2f(1, 1); glVertex2i(minBar + m_volEffects, centerY - Height() * 0.05); + glTexCoord2f(0, 1); glVertex2i(minBar, centerY - Height() * 0.05); + glEnd(); + glColor4f(1.0f, 1.0f, 1.0f, 1.0f); } @@ -727,6 +727,9 @@ void Engine::DisplayGraphicsMenu(float centerX, float centerY) { } void Engine::DisplayGameplayMenu(float centerX, float centerY) { + float minBar = centerX - Width() * 0.15; + float maxBar = centerX + Width() * 0.3; + glColor4f(1.0f, 0.5f, 0.0f, 1.0f); m_textureSensibilite.Bind(); glBegin(GL_QUADS); @@ -736,14 +739,22 @@ void Engine::DisplayGameplayMenu(float centerX, float centerY) { glTexCoord2f(0, 1); glVertex2i(centerX - Width() * 0.15, centerY + Height() * 0.25); glEnd(); - glColor4f(0.0f, 0.0f, 0.0f, 1.0f); - glBindTexture(GL_TEXTURE_2D, 0); - glBegin(GL_QUADS); - glTexCoord2f(0, 0); glVertex2i(centerX - Width() * 0.15, centerY + Height() * 0.165); - glTexCoord2f(1, 0); glVertex2i(centerX + Width() * 0.3, centerY + Height() * 0.165); - glTexCoord2f(1, 1); glVertex2i(centerX + Width() * 0.3, centerY + Height() * 0.2); - glTexCoord2f(0, 1); glVertex2i(centerX - Width() * 0.15, centerY + Height() * 0.2); - glEnd(); + glColor4f(0.0f, 0.0f, 0.0f, 1.0f); + glBindTexture(GL_TEXTURE_2D, 0); + glBegin(GL_QUADS); + glTexCoord2f(0, 0); glVertex2i(centerX - Width() * 0.15, centerY + Height() * 0.165); + glTexCoord2f(1, 0); glVertex2i(centerX + Width() * 0.3, centerY + Height() * 0.165); + glTexCoord2f(1, 1); glVertex2i(centerX + Width() * 0.3, centerY + Height() * 0.2); + glTexCoord2f(0, 1); glVertex2i(centerX - Width() * 0.15, centerY + Height() * 0.2); + glEnd(); + + glColor4f(0.0f, 1.0f, 0.0f, 1.0f); + glBegin(GL_QUADS); + glTexCoord2f(0, 0); glVertex2i(minBar, centerY + Height() * 0.165); + glTexCoord2f(1, 0); glVertex2i(minBar + m_volSensible, centerY + Height() * 0.165); + glTexCoord2f(1, 1); glVertex2i(minBar + m_volSensible, centerY + Height() * 0.2); + glTexCoord2f(0, 1); glVertex2i(minBar, centerY + Height() * 0.2); + glEnd(); glColor4f(1.0f, 1.0f, 1.0f, 1.0f); } @@ -1780,12 +1791,18 @@ void Engine::MousePressEvent(const MOUSE_BUTTON& button, int x, int y) { if (m_selectedOption == 0 && x > leftBar && x < rightBar && y > bottomBarPrincipal && y < topBarPrincipal) { std::cout << "Hit PRINCIPAL BAR" << std::endl; + m_volMain = x - leftBar; + m_selectedPrincipalBar = true; } else if (m_selectedOption == 0 && x > leftBar && x < rightBar && y > bottomBarMusique && y < topBarMusique) { std::cout << "Hit MUSIQUE BAR" << std::endl; + m_volMusic = x - leftBar; + m_selectedMusicBar = true; } else if (m_selectedOption == 0 && x > leftBar && x < rightBar && y > bottomBarEffets && y < topBarEffets) { std::cout << "Hit EFFETS BAR" << std::endl; + m_volEffects = x - leftBar; + m_selectedEffectsBar = true; } // Resolution @@ -1824,6 +1841,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) { std::cout << "Hit SENSIBILITE BAR" << std::endl; + m_volSensible = x - leftBar; + m_selectedSensibilityBar = true; } } else if (m_gamestate == GameState::SINGLEMULTI) @@ -1862,6 +1881,10 @@ void Engine::MouseReleaseEvent(const MOUSE_BUTTON& button, int x, int y) { case MOUSE_BUTTON_LEFT: m_mouseL = false; m_block = false; + m_selectedPrincipalBar = false; + m_selectedMusicBar = false; + m_selectedEffectsBar = false; + m_selectedSensibilityBar = false; break; case MOUSE_BUTTON_RIGHT: m_mouseR = false; diff --git a/SQCSim2021/engine.h b/SQCSim2021/engine.h index 4d8af4a..4548e58 100644 --- a/SQCSim2021/engine.h +++ b/SQCSim2021/engine.h @@ -151,8 +151,19 @@ private: int m_countdown = COUNTDOWN; int m_nbReductionChunk = 4; int m_timerReductionChunk = 30; + + float m_volMain = 50.0f; + float m_volMusic = 50.0f; + float m_volEffects = 50.0f; + float m_volSensible = 50.0f; + int m_selectedOption = 0; + bool m_selectedPrincipalBar = false; + bool m_selectedMusicBar = false; + bool m_selectedEffectsBar = false; + bool m_selectedSensibilityBar = false; + bool m_damage = false; bool m_wireframe = false;