Push menu options de base
@ -87,8 +87,6 @@ void Engine::DrawMenu()
|
||||
static const int sButton = 225;
|
||||
|
||||
glDisable(GL_LIGHTING);
|
||||
|
||||
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glDisable(GL_STENCIL_TEST);
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
@ -130,8 +128,6 @@ void Engine::DrawMenu()
|
||||
glVertex2i(0, 300);
|
||||
glEnd();
|
||||
|
||||
|
||||
|
||||
MenuStartTexture.Bind();
|
||||
glTranslated(80, -225, 0);
|
||||
glBegin(GL_QUADS);
|
||||
@ -145,20 +141,6 @@ void Engine::DrawMenu()
|
||||
glVertex2i(0, 200);
|
||||
glEnd();
|
||||
|
||||
|
||||
/*MenuResumeTexture.Bind();
|
||||
glTranslated(0, -100, 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();*/
|
||||
|
||||
MenuOptionsTexture.Bind();
|
||||
glTranslated(0, -100, 0);
|
||||
glBegin(GL_QUADS);
|
||||
@ -283,43 +265,102 @@ void Engine::DrawOption()
|
||||
static const int sTitle = 400;
|
||||
static const int sButton = 225;
|
||||
|
||||
glDisable(GL_LIGHTING);
|
||||
int centerX = Width() * 0.5f;
|
||||
int centerY = Height() * 0.5f;
|
||||
|
||||
GLint viewport[4];
|
||||
glGetIntegerv(GL_VIEWPORT, viewport);
|
||||
|
||||
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(Width(), 0); //
|
||||
glTexCoord2f(1, 1);
|
||||
glVertex2i(Width(), Height());
|
||||
glTexCoord2f(0, 1);
|
||||
glVertex2i(0, Height());
|
||||
glEnd();
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glBlendEquation(GL_FUNC_ADD);
|
||||
glEnable(GL_BLEND);
|
||||
|
||||
//glEnable(GL_LIGHTING);
|
||||
glDisable(GL_BLEND);
|
||||
glDisable(GL_STENCIL_TEST);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glPushMatrix();
|
||||
|
||||
glLoadIdentity();
|
||||
glOrtho(0, Width(), 0, Height(), -1, 1);
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glPushMatrix();
|
||||
|
||||
MenuBGFlouTexture.Bind();
|
||||
glLoadIdentity();
|
||||
glBegin(GL_QUADS);
|
||||
glTexCoord2f(0, 0); glVertex2i(0, 0);
|
||||
glTexCoord2f(1, 0); glVertex2i(Width(), 0);
|
||||
glTexCoord2f(1, 1); glVertex2i(Width(), Height());
|
||||
glTexCoord2f(0, 1); glVertex2i(0, Height());
|
||||
glEnd();
|
||||
|
||||
glColor4f(0.85f, 0.95f, 0.0f, 1.0f);
|
||||
m_textureOptions.Bind();
|
||||
glBegin(GL_QUADS);
|
||||
glTexCoord2f(0, 0); glVertex2i(centerX - Width() * 0.175, centerY + Height() * 0.35);
|
||||
glTexCoord2f(1, 0); glVertex2i(centerX + Width() * 0.175, centerY + Height() * 0.35);
|
||||
glTexCoord2f(1, 1); glVertex2i(centerX + Width() * 0.175, centerY + Height() * 0.45);
|
||||
glTexCoord2f(0, 1); glVertex2i(centerX - Width() * 0.175, centerY + Height() * 0.45);
|
||||
glEnd();
|
||||
|
||||
if (m_selectedOption == 0) {
|
||||
glColor4f(1.0f, 0.5f, 0.0f, 1.0f);
|
||||
}
|
||||
m_textureVolume.Bind();
|
||||
glBegin(GL_QUADS);
|
||||
glTexCoord2f(0, 0); glVertex2i(centerX - Width() * 0.35, centerY + Height() * 0.2);
|
||||
glTexCoord2f(1, 0); glVertex2i(centerX - Width() * 0.2, centerY + Height() * 0.2);
|
||||
glTexCoord2f(1, 1); glVertex2i(centerX - Width() * 0.2, centerY + Height() * 0.25);
|
||||
glTexCoord2f(0, 1); glVertex2i(centerX - Width() * 0.35, centerY + Height() * 0.25);
|
||||
glEnd();
|
||||
|
||||
glColor4f(0.85f, 0.95f, 0.0f, 1.0f);
|
||||
if (m_selectedOption == 1) {
|
||||
glColor4f(1.0f, 0.5f, 0.0f, 1.0f);
|
||||
}
|
||||
m_textureGraphiques.Bind();
|
||||
glBegin(GL_QUADS);
|
||||
glTexCoord2f(0, 0); glVertex2i(centerX - Width() * 0.4, centerY + Height() * 0.05);
|
||||
glTexCoord2f(1, 0); glVertex2i(centerX - Width() * 0.2, centerY + Height() * 0.05);
|
||||
glTexCoord2f(1, 1); glVertex2i(centerX - Width() * 0.2, centerY + Height() * 0.1);
|
||||
glTexCoord2f(0, 1); glVertex2i(centerX - Width() * 0.4, centerY + Height() * 0.1);
|
||||
glEnd();
|
||||
|
||||
glColor4f(0.85f, 0.95f, 0.0f, 1.0f);
|
||||
if (m_selectedOption == 2) {
|
||||
glColor4f(1.0f, 0.5f, 0.0f, 1.0f);
|
||||
}
|
||||
m_textureGameplay.Bind();
|
||||
glBegin(GL_QUADS);
|
||||
glTexCoord2f(0, 0); glVertex2i(centerX - Width() * 0.375, centerY - Height() * 0.1);
|
||||
glTexCoord2f(1, 0); glVertex2i(centerX - Width() * 0.2, centerY - Height() * 0.1);
|
||||
glTexCoord2f(1, 1); glVertex2i(centerX - Width() * 0.2, centerY - Height() * 0.05);
|
||||
glTexCoord2f(0, 1); glVertex2i(centerX - Width() * 0.375, centerY - Height() * 0.05);
|
||||
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.175, centerY - Height() * 0.1);
|
||||
glTexCoord2f(1, 0); glVertex2i(centerX - Width() * 0.1751, centerY - Height() * 0.1);
|
||||
glTexCoord2f(1, 1); glVertex2i(centerX - Width() * 0.1751, centerY + Height() * 0.25);
|
||||
glTexCoord2f(0, 1); glVertex2i(centerX - Width() * 0.175, centerY + Height() * 0.25);
|
||||
glEnd();
|
||||
|
||||
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
|
||||
glViewport(viewport[0], viewport[1], viewport[2], viewport[3]);
|
||||
|
||||
glEnable(GL_STENCIL_TEST);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glPopMatrix();
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glPopMatrix();
|
||||
ShowCursor();
|
||||
}
|
||||
|
||||
void Engine::Init() {
|
||||
@ -355,10 +396,8 @@ void Engine::Init() {
|
||||
return;
|
||||
else m_istarted = true;
|
||||
|
||||
//
|
||||
// Objet de skybox avec sa propre texture et son propre shader!
|
||||
m_skybox.Init(0.2f);
|
||||
//m_skybox2.Init(1.f);
|
||||
// Objet de musique!
|
||||
//m_audio.ToggleMusicState();
|
||||
|
||||
@ -442,11 +481,21 @@ void Engine::LoadResource() {
|
||||
LoadTexture(m_textureMultiText, TEXTURE_PATH "multi_player.png", false);
|
||||
LoadTexture(m_textureSoloMultiMenu, TEXTURE_PATH "single_multi.png", false);
|
||||
LoadTexture(m_textureTitle, TEXTURE_PATH "title.png", false);
|
||||
LoadTexture(m_textureOptions, TEXTURE_PATH "Bouton/options.png", false);
|
||||
LoadTexture(m_textureVolume, TEXTURE_PATH "Bouton/volume.png", false);
|
||||
LoadTexture(m_textureMusique, TEXTURE_PATH "Bouton/musique.png", false);
|
||||
LoadTexture(m_textureGraphiques, TEXTURE_PATH "Bouton/graphiques.png", false);
|
||||
LoadTexture(m_textureSensibilite, TEXTURE_PATH "Bouton/sensibilite.png", false);
|
||||
LoadTexture(m_textureResolution, TEXTURE_PATH "Bouton/resolution.png", false);
|
||||
LoadTexture(m_texturePrincipal, TEXTURE_PATH "Bouton/principal.png", false);
|
||||
LoadTexture(m_textureEffets, TEXTURE_PATH "Bouton/effets.png", false);
|
||||
LoadTexture(m_textureGameplay, TEXTURE_PATH "Bouton/gameplay.png", false);
|
||||
|
||||
// Pourquoi on load 3 fois la meme texture?
|
||||
LoadTexture(MenuTitleTexture, TEXTURE_PATH "BrouillonbackgroundMenu.png");
|
||||
LoadTexture(MenuBGTexture, TEXTURE_PATH "BrouillonbackgroundMenu.png");
|
||||
|
||||
LoadTexture(MenuBGOptionTexture, TEXTURE_PATH "BrouillonbackgroundMenu.png");
|
||||
LoadTexture(MenuBGFlouTexture, TEXTURE_PATH "BackgroundMenuFlou.png");
|
||||
|
||||
LoadTexture(SplachScreenTexture, TEXTURE_PATH "sc2.png");
|
||||
LoadTexture(MenuQuitTexture, MENU_ITEM_PATH "BasicQuit.png");
|
||||
@ -693,9 +742,7 @@ void Engine::DisplayPovGun() {
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
void Engine::DisplayCurrentItem() {
|
||||
}
|
||||
|
||||
void Engine::DisplayCurrentItem() {}
|
||||
|
||||
void Engine::DisplayHud(int timer) {
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
@ -975,6 +1022,10 @@ void Engine::DisplaySingleOrMultiplayerMenu() {
|
||||
ShowCursor();
|
||||
}
|
||||
|
||||
void Engine::DisplayAudioMenu() {
|
||||
|
||||
}
|
||||
|
||||
void Engine::DrawHud(float elapsedTime, BlockType bloc) {
|
||||
// Setter le blend function, tout ce qui sera noir sera transparent
|
||||
glDisable(GL_STENCIL_TEST);
|
||||
@ -1082,6 +1133,10 @@ int Engine::GetCountdown(float elapsedTime) {
|
||||
return m_countdown - (int)m_time;
|
||||
}
|
||||
|
||||
int Engine::GetOptionsChoice() {
|
||||
return m_selectedOption;
|
||||
}
|
||||
|
||||
void Engine::Render(float elapsedTime) {
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
||||
|
||||
@ -1307,7 +1362,7 @@ void Engine::Render(float elapsedTime) {
|
||||
}
|
||||
else if (m_gamestate == GameState::SINGLEMULTI)
|
||||
DisplaySingleOrMultiplayerMenu();
|
||||
else if (m_gamestate == GameState::OPTIONS)
|
||||
else if (m_gamestate == GameState::OPTIONS || m_gamestate == GameState::PAUSE)
|
||||
{
|
||||
DrawOption();
|
||||
}
|
||||
@ -1524,6 +1579,38 @@ void Engine::MousePressEvent(const MOUSE_BUTTON& button, int x, int y) {
|
||||
if ((m_mousemx >= 305 && m_mousemx <= 450) && (m_mousemy >= 450 && m_mousemy <= 500))
|
||||
m_gamestate = GameState::QUIT;
|
||||
}
|
||||
else if (m_gamestate == GameState::OPTIONS) {
|
||||
float centerX = Width() * 0.5f;
|
||||
float centerY = Height() * 0.5f;
|
||||
|
||||
float leftVol = centerX - Width() * 0.35f;
|
||||
float rightVol = centerX - Width() * 0.2f;
|
||||
float topVol = (Height() * 0.25f) + ((Height() * 0.25f) - (Height() * 0.2f));
|
||||
float bottomVol = (Height() * 0.2f) + ((Height() * 0.25f) - (Height() * 0.2f));
|
||||
|
||||
float leftGraph = centerX - Width() * 0.4f;
|
||||
float rightGraph = centerX - Width() * 0.2f;
|
||||
float topGraph = centerY - Height() * 0.05f;
|
||||
float bottomGraph = centerY - Height() * 0.1f;
|
||||
|
||||
float leftGameplay = centerX - Width() * 0.375f;
|
||||
float rightGameplay = centerX - Width() * 0.2f;
|
||||
float topGameplay = centerY + Height() * 0.1f;
|
||||
float bottomGameplay = centerY + Height() * 0.05f;
|
||||
|
||||
if (x > leftVol && x < rightVol && y > bottomVol && y < topVol) {
|
||||
m_selectedOption = 0; // Volume
|
||||
}
|
||||
else if (x > leftGraph && x < rightGraph && y > bottomGraph && y < topGraph) {
|
||||
m_selectedOption = 1; // Graphics
|
||||
}
|
||||
else if (x > leftGameplay && x < rightGameplay && y > bottomGameplay && y < topGameplay) {
|
||||
m_selectedOption = 2; // Gameplay
|
||||
}
|
||||
else {
|
||||
m_selectedOption = -1;
|
||||
}
|
||||
}
|
||||
else if (m_gamestate == GameState::SINGLEMULTI)
|
||||
{
|
||||
float buttonWidthProportion = 0.4f;
|
||||
|
@ -47,6 +47,7 @@ public:
|
||||
private:
|
||||
int GetFps(float elapsedTime) const;
|
||||
int GetCountdown(float elapsedTime);
|
||||
int GetOptionsChoice();
|
||||
|
||||
bool LoadTexture(Texture& texture, const std::string& filename, bool useMipmaps = true, bool stopOnError = true);
|
||||
|
||||
@ -54,15 +55,16 @@ private:
|
||||
void SystemNotification(std::string systemLog);
|
||||
void KillNotification(Player killer, Player killed);
|
||||
void DisplayNotification(std::string message);
|
||||
void ProcessNotificationQueue();
|
||||
void DisplayCrosshair();
|
||||
void DisplayPovGun();
|
||||
void DisplayCurrentItem();
|
||||
void DisplayHud(int timer);
|
||||
void DisplayInfo(float elapsedTime, BlockType bloc);
|
||||
void DisplaySingleOrMultiplayerMenu();
|
||||
void DisplayAudioMenu();
|
||||
void DrawHud(float elapsedTime, BlockType bloc);
|
||||
void PrintText(float x, float y, const std::string& t, float charSizeMultiplier = 1.0f);
|
||||
void ProcessNotificationQueue();
|
||||
|
||||
Connector m_conn;
|
||||
Shader m_shader01;
|
||||
@ -84,6 +86,16 @@ private:
|
||||
Texture m_textureSoloText;
|
||||
Texture m_textureMultiText;
|
||||
Texture m_textureTitle;
|
||||
Texture m_textureOptions;
|
||||
Texture m_textureVolume;
|
||||
Texture m_textureMusique;
|
||||
Texture m_textureGraphiques;
|
||||
Texture m_textureSensibilite;
|
||||
Texture m_textureResolution;
|
||||
Texture m_texturePrincipal;
|
||||
Texture m_textureEffets;
|
||||
Texture m_textureGameplay
|
||||
;
|
||||
|
||||
TextureAtlas::TextureIndex texBoostHeal;
|
||||
|
||||
@ -104,11 +116,12 @@ private:
|
||||
std::chrono::high_resolution_clock::time_point m_startTime;
|
||||
|
||||
//Menu
|
||||
enum class GameState: uint8_t { MAIN_MENU, OPTIONS, QUIT, NEWG, PLAY, PAUSE, SINGLEMULTI };
|
||||
enum class GameState: uint8_t { MAIN_MENU, OPTIONS, SETTINGS, QUIT, NEWG, PLAY, PAUSE, SINGLEMULTI };
|
||||
|
||||
GameState m_gamestate = GameState::MAIN_MENU;
|
||||
Texture MenuTitleTexture;
|
||||
Texture MenuBGTexture;
|
||||
Texture MenuBGFlouTexture;
|
||||
Texture MenuBGOptionTexture;
|
||||
Texture MenuStartTexture;
|
||||
Texture MenuQuitTexture;
|
||||
@ -130,6 +143,7 @@ private:
|
||||
int m_countdown = COUNTDOWN;
|
||||
int m_nbReductionChunk = 4;
|
||||
int m_timerReductionChunk = 30;
|
||||
int m_selectedOption = 0;
|
||||
|
||||
bool m_damage = false;
|
||||
|
||||
|
BIN
SQCSim2021/media/textures/BackgroundMenuFlou.png
Normal file
After Width: | Height: | Size: 1.6 MiB |
Before Width: | Height: | Size: 7.8 KiB |
Before Width: | Height: | Size: 8.6 KiB |
BIN
SQCSim2021/media/textures/Bouton/effets.png
Normal file
After Width: | Height: | Size: 2.6 KiB |
BIN
SQCSim2021/media/textures/Bouton/gameplay.png
Normal file
After Width: | Height: | Size: 3.9 KiB |
BIN
SQCSim2021/media/textures/Bouton/graphiques.png
Normal file
After Width: | Height: | Size: 4.7 KiB |
BIN
SQCSim2021/media/textures/Bouton/musique.png
Normal file
After Width: | Height: | Size: 2.7 KiB |
BIN
SQCSim2021/media/textures/Bouton/options.png
Normal file
After Width: | Height: | Size: 2.9 KiB |
BIN
SQCSim2021/media/textures/Bouton/principal.png
Normal file
After Width: | Height: | Size: 3.3 KiB |
BIN
SQCSim2021/media/textures/Bouton/resolution.png
Normal file
After Width: | Height: | Size: 3.5 KiB |
BIN
SQCSim2021/media/textures/Bouton/sensibilite.png
Normal file
After Width: | Height: | Size: 4.4 KiB |
BIN
SQCSim2021/media/textures/Bouton/volume.png
Normal file
After Width: | Height: | Size: 2.7 KiB |