From e5189f437c88a3c76737328e65cfc48d13d8379a Mon Sep 17 00:00:00 2001 From: Rynort Date: Mon, 30 Oct 2023 15:49:17 -0400 Subject: [PATCH] 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;