commit
a4a99ed425
@ -275,6 +275,45 @@ 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();
|
||||
|
||||
PauseBGTexture.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();
|
||||
|
||||
glDisable(GL_BLEND);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glPopMatrix();
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glPopMatrix();
|
||||
ShowCursor();
|
||||
}
|
||||
|
||||
void Engine::Init() {
|
||||
|
||||
|
||||
@ -390,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");
|
||||
@ -1132,6 +1173,10 @@ void Engine::Render(float elapsedTime) {
|
||||
DrawMenu();
|
||||
}
|
||||
}
|
||||
else if (m_gamestate == GameState::PAUSE)
|
||||
{
|
||||
DrawPause();
|
||||
}
|
||||
else if (m_gamestate == GameState::QUIT)
|
||||
Stop();
|
||||
}
|
||||
@ -1159,7 +1204,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
|
||||
|
@ -26,6 +26,7 @@ public:
|
||||
Engine();
|
||||
virtual ~Engine();
|
||||
virtual void DrawMenu();
|
||||
virtual void DrawPause();
|
||||
virtual void DrawSplachScreen();
|
||||
virtual void Init();
|
||||
virtual void DeInit();
|
||||
@ -90,13 +91,14 @@ private:
|
||||
std::map<uint64_t, Player*> m_players;
|
||||
|
||||
//Menu
|
||||
enum class GameState: uint8_t { MAIN_MENU, OPTIONS, QUIT, NEWG, PLAY };
|
||||
enum class GameState: uint8_t { MAIN_MENU, OPTIONS, QUIT, NEWG, PLAY, PAUSE };
|
||||
GameState m_gamestate = GameState::MAIN_MENU;
|
||||
Texture MenuTitleTexture;
|
||||
Texture MenuBGTexture;
|
||||
Texture MenuStartTexture;
|
||||
Texture MenuQuitTexture;
|
||||
Texture MenuOptionsTexture;
|
||||
Texture PauseBGTexture;
|
||||
Texture SplachScreenTexture;
|
||||
|
||||
float m_scale;
|
||||
|
Loading…
Reference in New Issue
Block a user