Finission du code pour le Pause

This commit is contained in:
Rynort 2023-10-30 15:49:17 -04:00
parent 85f4f82660
commit e5189f437c
2 changed files with 20 additions and 3 deletions

View File

@ -239,7 +239,7 @@ void Engine::DrawPause()
glMatrixMode(GL_MODELVIEW); glMatrixMode(GL_MODELVIEW);
glPushMatrix(); glPushMatrix();
MenuBGTexture.Bind(); PauseBGTexture.Bind();
glLoadIdentity(); glLoadIdentity();
glBegin(GL_QUADS); glBegin(GL_QUADS);
glTexCoord2f(0, 0); glTexCoord2f(0, 0);
@ -251,6 +251,14 @@ void Engine::DrawPause()
glTexCoord2f(0, 1); glTexCoord2f(0, 1);
glVertex2i(0, 600); glVertex2i(0, 600);
glEnd(); glEnd();
glDisable(GL_BLEND);
glEnable(GL_DEPTH_TEST);
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
ShowCursor();
} }
void Engine::Init() { void Engine::Init() {
@ -329,6 +337,7 @@ void Engine::LoadResource() {
LoadTexture(MenuTitleTexture, MENU_ITEM_PATH "test.png"); LoadTexture(MenuTitleTexture, MENU_ITEM_PATH "test.png");
LoadTexture(MenuBGTexture, 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(MenuQuitTexture, MENU_ITEM_PATH "BasicQuit.png");
LoadTexture(MenuOptionsTexture, MENU_ITEM_PATH "test.png"); LoadTexture(MenuOptionsTexture, MENU_ITEM_PATH "test.png");
LoadTexture(MenuStartTexture, MENU_ITEM_PATH "BasicPlay.png"); LoadTexture(MenuStartTexture, MENU_ITEM_PATH "BasicPlay.png");
@ -801,7 +810,7 @@ void Engine::Render(float elapsedTime) {
} }
else if (m_gamestate == GameState::PAUSE) else if (m_gamestate == GameState::PAUSE)
{ {
DrawPause();
} }
else if (m_gamestate == GameState::QUIT) else if (m_gamestate == GameState::QUIT)
Stop(); Stop();
@ -830,7 +839,14 @@ void Engine::KeyPressEvent(unsigned char key) {
} }
break; break;
case 36: // ESC - Quitter 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(); //Stop();
break; break;
case 57: // Space - Sauter case 57: // Space - Sauter

View File

@ -88,6 +88,7 @@ private:
Texture MenuStartTexture; Texture MenuStartTexture;
Texture MenuQuitTexture; Texture MenuQuitTexture;
Texture MenuOptionsTexture; Texture MenuOptionsTexture;
Texture PauseBGTexture;
float m_scale; float m_scale;
float m_time = 0; float m_time = 0;