From 85f4f82660a623f48a335017917444152850a52c Mon Sep 17 00:00:00 2001 From: Rynort Date: Mon, 23 Oct 2023 17:51:29 -0400 Subject: [PATCH 1/3] avancement menu pause --- SQCSim2021/engine.cpp | 41 ++++++++++++++++++++++++++++++++++++++--- SQCSim2021/engine.h | 3 ++- 2 files changed, 40 insertions(+), 4 deletions(-) diff --git a/SQCSim2021/engine.cpp b/SQCSim2021/engine.cpp index a5939e6..ee279dd 100644 --- a/SQCSim2021/engine.cpp +++ b/SQCSim2021/engine.cpp @@ -222,6 +222,37 @@ void Engine::DrawMenu() ShowCursor(); } +void Engine::DrawPause() +{ + static const int sTitle = 400; + static const int sButton = 225; + + glDisable(GL_LIGHTING); + + + glDisable(GL_DEPTH_TEST); + glDisable(GL_STENCIL_TEST); + glMatrixMode(GL_PROJECTION); + glPushMatrix(); + glLoadIdentity(); + glOrtho(0, Width(), 0, Height(), -1, 1); + glMatrixMode(GL_MODELVIEW); + glPushMatrix(); + + MenuBGTexture.Bind(); + glLoadIdentity(); + glBegin(GL_QUADS); + glTexCoord2f(0, 0); + glVertex2i(0, 0); + glTexCoord2f(1, 0); + glVertex2i(800, 0); + glTexCoord2f(1, 1); + glVertex2i(800, 600); + glTexCoord2f(0, 1); + glVertex2i(0, 600); + glEnd(); +} + void Engine::Init() { GLenum glewErr = glewInit(); if (glewErr != GLEW_OK) { @@ -684,11 +715,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(), .8f); + m_audio.Create3DAudioObj(step, AUDIO_PATH "step.wav", vstep, m_player.GetVelocity(), .8f, false); leftright = !leftright; break; case Player::Sound::FALL: - m_audio.Create3DAudioObj(step, AUDIO_PATH "hit.wav", m_player.GetPosition(), m_player.GetVelocity(), 1.f); + m_audio.Create3DAudioObj(step, AUDIO_PATH "hit.wav", m_player.GetPosition(), m_player.GetVelocity(), 1.f, false); break; default: break; } @@ -755,7 +786,7 @@ void Engine::Render(float elapsedTime) { static bool fell = false; if (m_player.GetPosition().y < 1.7f && !fell) { - m_audio.Create3DAudioObj(m_scream, AUDIO_PATH "scream.wav", m_player.GetPOV(), m_player.GetVelocity(), 1.f); + m_audio.Create3DAudioObj(m_scream, AUDIO_PATH "scream.wav", m_player.GetPOV(), m_player.GetVelocity(), 1.f, false); fell = true; } else if (m_player.GetPosition().y < -20.f) { @@ -767,6 +798,10 @@ void Engine::Render(float elapsedTime) { else if (m_gamestate == GameState::MAIN_MENU || m_gamestate == GameState::OPTIONS) { DrawMenu(); + } + else if (m_gamestate == GameState::PAUSE) + { + } else if (m_gamestate == GameState::QUIT) Stop(); diff --git a/SQCSim2021/engine.h b/SQCSim2021/engine.h index 57b4e2e..07e1211 100644 --- a/SQCSim2021/engine.h +++ b/SQCSim2021/engine.h @@ -25,6 +25,7 @@ public: Engine(); virtual ~Engine(); virtual void DrawMenu(); + virtual void DrawPause(); virtual void Init(); virtual void DeInit(); virtual void LoadResource(); @@ -80,7 +81,7 @@ private: Bullet* m_bullets[MAX_BULLETS]; //Menu - enum class GameState { MAIN_MENU, OPTIONS, QUIT, NEWG, PLAY }; + enum class GameState { MAIN_MENU, OPTIONS, QUIT, NEWG, PLAY, PAUSE }; GameState m_gamestate = GameState::MAIN_MENU; Texture MenuTitleTexture; Texture MenuBGTexture; From e5189f437c88a3c76737328e65cfc48d13d8379a Mon Sep 17 00:00:00 2001 From: Rynort Date: Mon, 30 Oct 2023 15:49:17 -0400 Subject: [PATCH 2/3] Finission du code pour le Pause --- SQCSim2021/engine.cpp | 22 +++++++++++++++++++--- SQCSim2021/engine.h | 1 + 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/SQCSim2021/engine.cpp b/SQCSim2021/engine.cpp index ee279dd..84a8bfd 100644 --- a/SQCSim2021/engine.cpp +++ b/SQCSim2021/engine.cpp @@ -239,7 +239,7 @@ void Engine::DrawPause() glMatrixMode(GL_MODELVIEW); glPushMatrix(); - MenuBGTexture.Bind(); + PauseBGTexture.Bind(); glLoadIdentity(); glBegin(GL_QUADS); glTexCoord2f(0, 0); @@ -251,6 +251,14 @@ void Engine::DrawPause() glTexCoord2f(0, 1); glVertex2i(0, 600); glEnd(); + + glDisable(GL_BLEND); + glEnable(GL_DEPTH_TEST); + glMatrixMode(GL_PROJECTION); + glPopMatrix(); + glMatrixMode(GL_MODELVIEW); + glPopMatrix(); + ShowCursor(); } void Engine::Init() { @@ -329,6 +337,7 @@ void Engine::LoadResource() { LoadTexture(MenuTitleTexture, MENU_ITEM_PATH "test.png"); LoadTexture(MenuBGTexture, MENU_ITEM_PATH "test.png"); + LoadTexture(PauseBGTexture, MENU_ITEM_PATH "test.png"); LoadTexture(MenuQuitTexture, MENU_ITEM_PATH "BasicQuit.png"); LoadTexture(MenuOptionsTexture, MENU_ITEM_PATH "test.png"); LoadTexture(MenuStartTexture, MENU_ITEM_PATH "BasicPlay.png"); @@ -801,7 +810,7 @@ void Engine::Render(float elapsedTime) { } else if (m_gamestate == GameState::PAUSE) { - + DrawPause(); } else if (m_gamestate == GameState::QUIT) Stop(); @@ -830,7 +839,14 @@ void Engine::KeyPressEvent(unsigned char key) { } break; case 36: // ESC - Quitter - m_gamestate = GameState::MAIN_MENU; + if (m_gamestate == GameState::PLAY) + { + m_gamestate = GameState::PAUSE; + } + else if (m_gamestate == GameState::PAUSE) + { + m_gamestate = GameState::PLAY; + } //Stop(); break; case 57: // Space - Sauter diff --git a/SQCSim2021/engine.h b/SQCSim2021/engine.h index 07e1211..522e1a8 100644 --- a/SQCSim2021/engine.h +++ b/SQCSim2021/engine.h @@ -88,6 +88,7 @@ private: Texture MenuStartTexture; Texture MenuQuitTexture; Texture MenuOptionsTexture; + Texture PauseBGTexture; float m_scale; float m_time = 0; From cd921b3ab336609083edf5325086f255497d7898 Mon Sep 17 00:00:00 2001 From: Rynort Date: Mon, 6 Nov 2023 16:04:34 -0500 Subject: [PATCH 3/3] =?UTF-8?q?R=C3=A9paration=20du=20Merge=20du=20Pause?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SQCSim2021/engine.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/SQCSim2021/engine.cpp b/SQCSim2021/engine.cpp index e80127f..9205360 100644 --- a/SQCSim2021/engine.cpp +++ b/SQCSim2021/engine.cpp @@ -429,10 +429,12 @@ void Engine::LoadResource() { LoadTexture(MenuTitleTexture, TEXTURE_PATH "BrouillonbackgroundMenu.png"); LoadTexture(MenuBGTexture, TEXTURE_PATH "BrouillonbackgroundMenu.png"); + LoadTexture(PauseBGTexture, TEXTURE_PATH "BrouillonbackgroundMenu.png"); LoadTexture(SplachScreenTexture, TEXTURE_PATH "sc2.png"); LoadTexture(MenuQuitTexture, MENU_ITEM_PATH "BasicQuit.png"); LoadTexture(MenuOptionsTexture, MENU_ITEM_PATH "test.png"); LoadTexture(MenuStartTexture, MENU_ITEM_PATH "BasicPlay.png"); + TextureAtlas::TextureIndex texDirtIndex = m_textureAtlas.AddTexture(TEXTURE_PATH "metal3.png"); TextureAtlas::TextureIndex texIceIndex = m_textureAtlas.AddTexture(TEXTURE_PATH "metal2.png"); TextureAtlas::TextureIndex texGrassIndex = m_textureAtlas.AddTexture(TEXTURE_PATH "grass.png");