From 9dd2e1b82146e36c3235fb1f8cca8a6001564cf7 Mon Sep 17 00:00:00 2001 From: mduval76 <9343789@etu.cegepsth.qc.ca> Date: Tue, 31 Oct 2023 11:11:14 -0400 Subject: [PATCH] Fix pour resize dynamique de la fenetre de jeu (positionnement et scalaires). Fix pour le maudit F10-fullscreen --- SQCSim2021/engine.cpp | 296 ++++++++++---------- SQCSim2021/engine.h | 4 +- SQCSim2021/media/textures/multi_player.png | Bin 3731 -> 1845 bytes SQCSim2021/media/textures/single_player.png | Bin 4081 -> 2176 bytes SQCSim2021/mesh.cpp | 2 +- 5 files changed, 157 insertions(+), 145 deletions(-) diff --git a/SQCSim2021/engine.cpp b/SQCSim2021/engine.cpp index 26cf983..dc1432a 100644 --- a/SQCSim2021/engine.cpp +++ b/SQCSim2021/engine.cpp @@ -429,16 +429,13 @@ void Engine::ProcessNotificationQueue() { //float fPosY = Height() - (Height() * 0.05) * scaleY; m_textureFont.Bind(); - - auto [scaleX, scaleY] = GetScale(); - - float xOffset = (Width() / 1.5f) * scaleX; - float yOffset = (Height() / 1.2f) * scaleY; + float xOffset = Width() * 0.66f; + float yOffset = Height() * 0.83f; for (auto it = notifications.begin(); it != notifications.end(); ) { float timeSinceDisplay = m_time - it->displayStartTime; - float y = yOffset - (20.0f * scaleX * (it - notifications.begin())); + float y = yOffset - (20.0f * (it - notifications.begin())); glDisable(GL_STENCIL_TEST); glDisable(GL_DEPTH_TEST); @@ -511,14 +508,13 @@ void Engine::DisplayPovGun() { glMatrixMode(GL_MODELVIEW); glPushMatrix(); - float scaleX = (Width()) / BASE_WIDTH; - float scaleY = (Height()) / BASE_HEIGHT; - float baseXOffset = 0.4958 * BASE_WIDTH; - float baseWidth = 0.4688 * BASE_WIDTH; - float baseHeight = 0.5787 * BASE_HEIGHT; - float xTranslation = baseXOffset * scaleX; - float quadWidth = baseWidth * scaleX; - float quadHeight = baseHeight * scaleY; + float baseXOffsetPercentage = 0.4958; + float baseWidthPercentage = 0.4688; + float baseHeightPercentage = 0.5787; + + float xTranslation = baseXOffsetPercentage * Width(); + float quadWidth = baseWidthPercentage * Width(); + float quadHeight = baseHeightPercentage * Height(); m_texturePovGun.Bind(); glLoadIdentity(); @@ -543,7 +539,6 @@ void Engine::DisplayPovGun() { glMatrixMode(GL_PROJECTION); glPopMatrix(); - glMatrixMode(GL_MODELVIEW); glPopMatrix(); } @@ -556,46 +551,53 @@ void Engine::DisplayHud(int timer) { glBindTexture(GL_TEXTURE_2D, 0); glLoadIdentity(); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - auto [scaleX, scaleY] = GetScale(); - float fBackPosX = (Width() / 25.0f) * scaleX; - float fBackPosY = (Height() - (Height() * 0.815) * scaleY); - float fBackWidth = (Width() / 4.0f) * scaleX; - float fBackHeight = (Height() / 5.5f) * scaleY; + float itemBackgroundWidthProportion = 0.25f; + float itemBackgroundHeightProportion = 0.175f; + float itemBackgroundWidth = Width() * itemBackgroundWidthProportion; + float itemBackgroundHeight = Height() * itemBackgroundHeightProportion; + float itemBackgroundXOffset = Width() * 0.05f; + float itemBackgroundYOffset = Height() * 0.6f; + float itemBackgroundXPos = itemBackgroundXOffset; + float itemBackgroundYPos = Height() - itemBackgroundHeight - itemBackgroundYOffset; + // Selected item background glColor4f(1.0f, 1.0f, 1.0f, 0.2f); glBegin(GL_QUADS); - glVertex2f(fBackPosX, fBackPosY); - glVertex2f(fBackPosX + fBackWidth, fBackPosY); - glVertex2f(fBackPosX + fBackWidth, fBackPosY + fBackHeight); - glVertex2f(fBackPosX, fBackPosY + fBackHeight); + glVertex2f(itemBackgroundXPos, itemBackgroundYPos); + glVertex2f(itemBackgroundXPos + itemBackgroundWidth, itemBackgroundYPos); + glVertex2f(itemBackgroundXPos + itemBackgroundWidth, itemBackgroundYPos + itemBackgroundHeight); + glVertex2f(itemBackgroundXPos, itemBackgroundYPos + itemBackgroundHeight); glEnd(); // HP Bar - float fBarWidth = (Width() / 4.0f) * scaleX; - float fBarHeight = (Height() / 25.0f) * scaleY; - float fPosX = (Width() / 25.0f) * scaleX; - float fBarPosY = (Height() - (Height() * 0.775) * scaleY); - float playerHp = m_player.GetHP(); float facteurOmbrage = m_displayInfo ? 0.5f : 1.0f; + float hpBarWidthProportion = 0.25f; + float hpBarHeightProportion = 0.045f; + float hpBarWidth = Width() * hpBarWidthProportion; + float hpBarHeight = Height() * hpBarHeightProportion; + float hpBarXOffset = Width() * 0.05f; + float hpBarYOffset = Height() * 0.7f; + float hpBarYPos = Height() - hpBarHeight - hpBarYOffset; + // HP Bar Background glColor3f(1.0f * facteurOmbrage, 1.0f * facteurOmbrage, 1.0f * facteurOmbrage); glBegin(GL_QUADS); - glVertex2f(fPosX, fBarPosY - fBarHeight); - glVertex2f(fPosX + fBarWidth, fBarPosY - fBarHeight); - glVertex2f(fPosX + fBarWidth, fBarPosY); - glVertex2f(fPosX, fBarPosY); + glVertex2f(itemBackgroundXPos, hpBarYPos - hpBarHeight); + glVertex2f(itemBackgroundXPos + itemBackgroundWidth, hpBarYPos - hpBarHeight); + glVertex2f(itemBackgroundXPos + itemBackgroundWidth, hpBarYPos); + glVertex2f(itemBackgroundXPos, hpBarYPos); glEnd(); // Current HP glColor3f(0.0f * facteurOmbrage, 1.0f * facteurOmbrage, 0.0f * facteurOmbrage); glBegin(GL_QUADS); - glVertex2f(fPosX, fBarPosY - fBarHeight); - glVertex2f(fPosX + fBarWidth * playerHp, fBarPosY - fBarHeight); - glVertex2f(fPosX + fBarWidth * playerHp, fBarPosY); - glVertex2f(fPosX, fBarPosY); + glVertex2f(itemBackgroundXPos, hpBarYPos - hpBarHeight); + glVertex2f(itemBackgroundXPos + itemBackgroundWidth * playerHp, hpBarYPos - hpBarHeight); + glVertex2f(itemBackgroundXPos + itemBackgroundWidth * playerHp, hpBarYPos); + glVertex2f(itemBackgroundXPos, hpBarYPos); glEnd(); // Equip Bar @@ -603,22 +605,23 @@ void Engine::DisplayHud(int timer) { glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glColor3f(1.0f * facteurOmbrage, 1.0f * facteurOmbrage, 1.0f * facteurOmbrage); - float fEquipWidth = (Width() * 0.175f) * scaleX; - float fEquipHeight = (fEquipWidth / 2.5) * scaleY; - float fEquipPosY = (Height() - (Height() * 0.765) * scaleY); + float equipWidthProportion = 0.8f; + float equipHeightProportion = 0.7f; + float equipWidth = itemBackgroundWidth * equipWidthProportion; + float equipHeight = itemBackgroundHeight * equipHeightProportion; + float equipXOffset = itemBackgroundXPos + (itemBackgroundWidth - equipWidth) * 0.1f; + float equipYOffset = itemBackgroundYPos + (itemBackgroundHeight - equipHeight) * 0.75f; - glTranslatef(fPosX, fEquipPosY, 0); + glTranslatef(equipXOffset, equipYOffset, 0); m_textureGun.Bind(); glBegin(GL_QUADS); - glTexCoord2f(0, 0); glVertex2i(0, 0); - glTexCoord2f(1, 0); glVertex2i(fEquipWidth, 0); - glTexCoord2f(1, 1); glVertex2i(fEquipWidth, fEquipHeight); - glTexCoord2f(0, 1); glVertex2i(0, fEquipHeight); + glTexCoord2f(0, 0); glVertex2f(0, 0); + glTexCoord2f(1, 0); glVertex2f(equipWidth, 0); + glTexCoord2f(1, 1); glVertex2f(equipWidth, equipHeight); + glTexCoord2f(0, 1); glVertex2f(0, equipHeight); glEnd(); - //glDisable(GL_BLEND); - // Username glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE); @@ -626,30 +629,37 @@ void Engine::DisplayHud(int timer) { m_textureFont.Bind(); std::ostringstream ss; - float fUsernamePosY = fBarPosY - (fBarHeight * 2) * scaleY; + float fUsernamePosY = hpBarYPos - (hpBarHeight * 2); ss.str(""); ss << m_player.GetUsername(); - PrintText(fPosX, fUsernamePosY, ss.str(), 1.5f); + PrintText(itemBackgroundXPos, fUsernamePosY, ss.str(), 1.5f); ss.str(""); ss << m_player.GetHP() * 100 << "%"; - PrintText(fPosX * 6.25, fUsernamePosY, ss.str(), 1.5f); + PrintText(itemBackgroundXPos * 5.25f, fUsernamePosY, ss.str(), 1.5f); + + float countdownXOffset = Width() * 0.2f; + float countdownYOffset = Height() * 0.1f; + float countdownXPos = Width() - countdownXOffset; + float countdownYPos = Height() - countdownYOffset; // Countdown ss.str(""); ss << "Time: " << (int)(timer / 60) << ":" << std::setw(2) << std::setfill('0') << timer % 60; - PrintText(Width() - (Width() * 0.2f) * scaleX, Height() - (Height() * 0.1) * scaleY, ss.str(), 2.0f); + PrintText(countdownXPos, countdownYPos, ss.str(), 2.0f); } void Engine::DisplayInfo(float elapsedTime, BlockType bloc) { m_textureFont.Bind(); std::ostringstream ss; - auto [scaleX, scaleY] = GetScale(); + float marginX = Width() * 0.01; + float marginY = Height() * 0.05; + + float fPosX = marginX; + float fPosY = Height() - marginY; - float fPosX = (Width() / 100.0f) * scaleX; - float fPosY = Height() - (Height() * 0.05) * scaleY; float charSize = 20 + (24 - 20) * (Width() - 1600) / (1920 - 1600); ss << " Fps : " << GetFps(elapsedTime); @@ -667,7 +677,7 @@ void Engine::DisplayInfo(float elapsedTime, BlockType bloc) { ss.str(""); fPosY -= charSize; - float fPosYJump = ((Height() - (Height() * 0.9f)) * scaleY); + float fPosYJump = Height() * 0.09; fPosY = fPosYJump; fPosY -= charSize; @@ -695,6 +705,9 @@ void Engine::DisplayInfo(float elapsedTime, BlockType bloc) { } void Engine::DisplaySingleOrMultiplayerMenu() { + GLint viewport[4]; + glGetIntegerv(GL_VIEWPORT, viewport); + glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendEquation(GL_FUNC_ADD); @@ -711,98 +724,92 @@ void Engine::DisplaySingleOrMultiplayerMenu() { glMatrixMode(GL_MODELVIEW); glPushMatrix(); - auto [scaleX, scaleY] = GetScale(); - float fBackPosX = 0.0f; - float fBackPosY = 0.0f; - float fBackWidth = Width(); - float fBackHeight = Height(); - + // Background m_textureSoloMultiMenu.Bind(); glBegin(GL_QUADS); - glTexCoord2f(0.0f, 0.0f); glVertex2f(fBackPosX, fBackPosY); - glTexCoord2f(1.0f, 0.0f); glVertex2f(fBackWidth, fBackPosY); - glTexCoord2f(1.0f, 1.0f); glVertex2f(fBackWidth, fBackHeight); - glTexCoord2f(0.0f, 1.0f); glVertex2f(fBackPosX, fBackHeight); + glTexCoord2f(0.0f, 0.0f); glVertex2f(0.0f, 0.0f); + glTexCoord2f(1.0f, 0.0f); glVertex2f(Width(), 0.0f); + glTexCoord2f(1.0f, 1.0f); glVertex2f(Width(), Height()); + glTexCoord2f(0.0f, 1.0f); glVertex2f(0.0f, Height()); glEnd(); - float centerX = (Width() / 2.0f); - float centerY = (Height() / 2.0f); - float titleWidth = (centerX * 1.85f) * scaleX; - float titleHeight = (centerY * 1.85f) * scaleY; - // Title - glColor4f(1.0f, 0.33f, 0.66f, 1.0f); + float titleWidthProportion = 0.4f; + float titleHeightProportion = 0.4f; + float titleWidth = titleWidthProportion * Width(); + float titleHeight = titleHeightProportion * Height(); + float offsetTitleXFactor = 0.05f; + float offsetTitleYFactor = 0.05f; + m_titleX = (Width() - titleWidth) - (offsetTitleXFactor * Width()); + m_titleY = (Height() - titleHeight) - (offsetTitleYFactor * Height()); + m_textureTitle.Bind(); + glColor4f(1.0f, 0.5f, 0.0f, 1.0f); glBegin(GL_QUADS); - glTexCoord2f(0.0f, 0.0f); glVertex2f(centerX, centerY); - glTexCoord2f(1.0f, 0.0f); glVertex2f(titleWidth, centerY); - glTexCoord2f(1.0f, 1.0f); glVertex2f(titleWidth, titleHeight); - glTexCoord2f(0.0f, 1.0f); glVertex2f(centerX, titleHeight); + glTexCoord2f(0.0f, 0.0f); glVertex2f(m_titleX, m_titleY); + glTexCoord2f(1.0f, 0.0f); glVertex2f(m_titleX + titleWidth, m_titleY); + glTexCoord2f(1.0f, 1.0f); glVertex2f(m_titleX + titleWidth, m_titleY + titleHeight); + glTexCoord2f(0.0f, 1.0f); glVertex2f(m_titleX, m_titleY + titleHeight); glEnd(); glBindTexture(GL_TEXTURE_2D, 0); - // Solo game indicator - float fPosX = (centerX * 1.1f) * scaleX; - float fPosXWidth = (centerX * 1.75f) * scaleX; - float soloPosY = (centerY * 0.75f) * scaleY; - float soloHeight = (centerY * 0.9f) * scaleY; + // Single Player and Multiplayer button background quads + float buttonWidthProportion = 0.4f; + float buttonHeightProportion = 0.075f; + float buttonWidth = buttonWidthProportion * Width(); + float buttonHeight = buttonHeightProportion * Height(); + float offsetSingleButtonXFactor = 0.075f; + float offsetSingleButtonYFactor = 0.05f; + float buttonPosX = m_titleX; + float buttonSinglePosY = m_titleY - buttonHeight - (offsetSingleButtonYFactor * Height()); + float buttonMultiPosY = (buttonSinglePosY * 0.75); + + // Single Player background glColor4f(1.0f, 1.0f, 1.0f, 0.5f); glBegin(GL_QUADS); - glTexCoord2f(0.0f, 0.0f); glVertex2f(fPosX, soloPosY); - glTexCoord2f(1.0f, 0.0f); glVertex2f(fPosXWidth, soloPosY); - glTexCoord2f(1.0f, 1.0f); glVertex2f(fPosXWidth, soloHeight); - glTexCoord2f(0.0f, 1.0f); glVertex2f(fPosX, soloHeight); + glTexCoord2f(0.0f, 0.0f); glVertex2f(buttonPosX, buttonSinglePosY); + glTexCoord2f(1.0f, 0.0f); glVertex2f(buttonPosX + buttonWidth, buttonSinglePosY); + glTexCoord2f(1.0f, 1.0f); glVertex2f(buttonPosX + buttonWidth, buttonSinglePosY + buttonHeight); + glTexCoord2f(0.0f, 1.0f); glVertex2f(buttonPosX, buttonSinglePosY + buttonHeight); glEnd(); - glBindTexture(GL_TEXTURE_2D, 0); - - float fPosXSoloText = (centerX * 0.75f) * scaleX; - float fPosXWidthSoloText = (centerX * 2.0f) * scaleX; - float soloPosYSoloText = (centerY * 0.35f) * scaleY; - float soloHeightSoloText = (centerY * 1.3) * scaleY; - + // Single Player text m_textureSoloText.Bind(); - glColor4f(0.5f, 0.0f, 0.5f, 1.0f); + glColor4f(0.75f, 0.05f, 0.0f, 1.0f); glBegin(GL_QUADS); - glTexCoord2f(0.0f, 0.0f); glVertex2f(fPosXSoloText, soloPosYSoloText); - glTexCoord2f(1.0f, 0.0f); glVertex2f(fPosXWidthSoloText, soloPosYSoloText); - glTexCoord2f(1.0f, 1.0f); glVertex2f(fPosXWidthSoloText, soloHeightSoloText); - glTexCoord2f(0.0f, 1.0f); glVertex2f(fPosXSoloText, soloHeightSoloText); + glTexCoord2f(0.0f, 0.0f); glVertex2f(buttonPosX, buttonSinglePosY); + glTexCoord2f(1.0f, 0.0f); glVertex2f(buttonPosX + buttonWidth, buttonSinglePosY); + glTexCoord2f(1.0f, 1.0f); glVertex2f(buttonPosX + buttonWidth, buttonSinglePosY + buttonHeight); + glTexCoord2f(0.0f, 1.0f); glVertex2f(buttonPosX, buttonSinglePosY + buttonHeight); glEnd(); glBindTexture(GL_TEXTURE_2D, 0); - - // Multiplayer game indicator - float multiPosY = (centerY * 0.5f) * scaleY; - float multiHeight = (centerY * 0.65f) * scaleY; - + // Multi Player background glColor4f(1.0f, 1.0f, 1.0f, 0.5f); glBegin(GL_QUADS); - glTexCoord2f(0.0f, 0.0f); glVertex2f(fPosX, multiPosY); - glTexCoord2f(1.0f, 0.0f); glVertex2f(fPosXWidth, multiPosY); - glTexCoord2f(1.0f, 1.0f); glVertex2f(fPosXWidth, multiHeight); - glTexCoord2f(0.0f, 1.0f); glVertex2f(fPosX, multiHeight); + glTexCoord2f(0.0f, 0.0f); glVertex2f(buttonPosX, buttonMultiPosY); + glTexCoord2f(1.0f, 0.0f); glVertex2f(buttonPosX + buttonWidth, buttonMultiPosY); + glTexCoord2f(1.0f, 1.0f); glVertex2f(buttonPosX + buttonWidth, buttonMultiPosY + buttonHeight); + glTexCoord2f(0.0f, 1.0f); glVertex2f(buttonPosX, buttonMultiPosY + buttonHeight); glEnd(); - - float fPosXMultiText = (centerX * 0.7f) * scaleX; - float fPosXWidthMultiText = (centerX * 2.0f) * scaleX; - float multiPosYMultiText = (centerY * 0.01f) * scaleY; - float multiHeightMultiText = (centerY * 1.0105) * scaleY; - + // Multi Player text m_textureMultiText.Bind(); - glColor4f(0.5f, 0.0f, 0.5f, 1.0f); + glColor4f(0.75f, 0.05f, 0.0f, 1.0f); glBegin(GL_QUADS); - glTexCoord2f(0.0f, 0.0f); glVertex2f(fPosXMultiText, multiPosYMultiText); - glTexCoord2f(1.0f, 0.0f); glVertex2f(fPosXWidthMultiText, multiPosYMultiText); - glTexCoord2f(1.0f, 1.0f); glVertex2f(fPosXWidthMultiText, multiHeightMultiText); - glTexCoord2f(0.0f, 1.0f); glVertex2f(fPosXMultiText, multiHeightMultiText); + glTexCoord2f(0.0f, 0.0f); glVertex2f(buttonPosX, buttonMultiPosY); + glTexCoord2f(1.0f, 0.0f); glVertex2f(buttonPosX + buttonWidth, buttonMultiPosY); + glTexCoord2f(1.0f, 1.0f); glVertex2f(buttonPosX + buttonWidth, buttonMultiPosY + buttonHeight); + glTexCoord2f(0.0f, 1.0f); glVertex2f(buttonPosX, buttonMultiPosY + buttonHeight); glEnd(); - // TODO: Add SOLO / MULTIPLAYER text with font + glColor4f(1.0f, 1.0f, 1.0f, 1.0f); + // Reset the state + glViewport(viewport[0], viewport[1], viewport[2], viewport[3]); + glEnable(GL_STENCIL_TEST); glEnable(GL_DEPTH_TEST); @@ -812,7 +819,6 @@ void Engine::DisplaySingleOrMultiplayerMenu() { glMatrixMode(GL_MODELVIEW); glPopMatrix(); - ShowCursor(); } @@ -872,10 +878,13 @@ void Engine::DrawHud(float elapsedTime, BlockType bloc) { } void Engine::PrintText(float x, float y, const std::string& t, float charSizeMultiplier) { - auto [scaleX, scaleY] = GetScale(); - float scale = std::min(scaleX, scaleY); + float windowWidth = static_cast(Width()); + float windowHeight = static_cast(Height()); - float baseCharSize = 20 + (24 - 20) * (Width() - 1600) / (1920 - 1600); + float posX = x * windowWidth; + float posY = y * windowHeight; + + float baseCharSize = 20 + (24 - 20) * (windowWidth - 1600) / (1920 - 1600); float charSize = baseCharSize * charSizeMultiplier; glLoadIdentity(); @@ -888,21 +897,15 @@ void Engine::PrintText(float x, float y, const std::string& t, float charSizeMul glBegin(GL_QUADS); glTexCoord2f(left, 1.f - top - .0625f); glVertex2f(0, 0); - glTexCoord2f(left + .0625f, 1.f - top - .0625f); glVertex2f(charSize * scale, 0); - glTexCoord2f(left + .0625f, 1.f - top); glVertex2f(charSize * scale, charSize * scale); - glTexCoord2f(left, 1.f - top); glVertex2f(0, charSize * scale); + glTexCoord2f(left + .0625f, 1.f - top - .0625f); glVertex2f(charSize, 0); + glTexCoord2f(left + .0625f, 1.f - top); glVertex2f(charSize, charSize); + glTexCoord2f(left, 1.f - top); glVertex2f(0, charSize); glEnd(); - glTranslated(0.5555f * charSize * scale, 0, 0); + glTranslated(0.5555f * charSize, 0, 0); } } -std::pair Engine::GetScale() const { - float widthRatio = static_cast(Width()) / BASE_WIDTH; - float heightRatio = static_cast(Height()) / BASE_HEIGHT; - return { widthRatio, heightRatio }; -} - int Engine::GetFps(float elapsedTime) const { return 1 / elapsedTime; } int Engine::GetCountdown(float elapsedTime) { if (m_resetcountdown) @@ -1243,22 +1246,31 @@ void Engine::MousePressEvent(const MOUSE_BUTTON& button, int x, int y) { } else if (m_gamestate == GameState::OPTIONS) { - auto [scaleX, scaleY] = GetScale(); - float soloLx = ((Width() / 2.0f) + 30) * scaleX; - float soloLy = ((Height() / 2.0f) + 20) * scaleY; - float soloRx = ((Width() / 2.0f) + 240) * scaleX; - float soloRy = ((Height() / 2.0f) + 60) * scaleY; + float buttonWidthProportion = 0.4f; + float buttonHeightProportion = 0.075f; + float buttonWidth = buttonWidthProportion * Width(); + float buttonHeight = buttonHeightProportion * Height(); + float offsetSingleButtonXFactor = 0.075f; + float offsetSingleButtonYFactor = 0.05f; - float multiLx = ((Width() / 2.0f) + 30) * scaleX; - float multiLy = ((Height() / 2.0f) + 85) * scaleY; - float multiRx = ((Width() / 2.0f) + 240) * scaleX; - float multiRy = ((Height() / 2.0f) + 120) * scaleY; + float buttonPosX = m_titleX; + float buttonSinglePosY = m_titleY - buttonHeight - (offsetSingleButtonYFactor * Height()); + float buttonMultiPosY = buttonSinglePosY * 0.75; + float adjustedMouseY = Height() - m_mousemy; - if (m_mousemx >= soloLx && m_mousemx <= soloRx && m_mousemy >= soloLy && m_mousemy <= soloRy) { + // Single Player + if (m_mousemx >= buttonPosX && m_mousemx <= (buttonPosX + buttonWidth) && + adjustedMouseY >= buttonSinglePosY && adjustedMouseY <= (buttonSinglePosY + buttonHeight)) + { + std::cout << "Single Player button clicked" << std::endl; m_soloMultiChoiceMade = true; m_gamestate = GameState::PLAY; } - else if (m_mousemx >= multiLx && m_mousemx <= multiRx && m_mousemy >= multiLy && m_mousemy <= multiRy) { + // Multiplayer + else if (m_mousemx >= buttonPosX && m_mousemx <= (buttonPosX + buttonWidth) && + adjustedMouseY >= buttonMultiPosY && adjustedMouseY <= (buttonMultiPosY + buttonHeight)) + { + std::cout << "Multiplayer button clicked" << std::endl; m_soloMultiChoiceMade = true; m_gamestate = GameState::PLAY; } diff --git a/SQCSim2021/engine.h b/SQCSim2021/engine.h index a12ec8a..96b5af6 100644 --- a/SQCSim2021/engine.h +++ b/SQCSim2021/engine.h @@ -38,8 +38,6 @@ public: virtual void MouseReleaseEvent(const MOUSE_BUTTON &button, int x, int y); private: - std::pair GetScale() const; - int GetFps(float elapsedTime) const; int GetCountdown(float elapsedTime); @@ -100,6 +98,8 @@ private: float m_scale; float m_time = 0; float m_time_SplashScreen = 0; + float m_titleX = 0; + float m_titleY = 0; float m_Width = 0; float m_Height = 0; diff --git a/SQCSim2021/media/textures/multi_player.png b/SQCSim2021/media/textures/multi_player.png index b013b441f8be1d3acff72721308c61306a67e8cb..d8db6e033c1b96c6a4ab848446cfd649bbc3c1c6 100644 GIT binary patch delta 1744 zcmV;>1~2)O9kmW2iBL{Q4GJ0x0000DNk~Le0004U0000}2nGNE0D_~8E|DQLWd_Pg zL_t(|UhUnxkK9xg$MGy3DM^KhfPxeVX@LR>iXfyA(LtFWiBv!u8VZm=lvKcffP_Q| z9U>JEkrL7%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LY4FM>lYyXp5RH?-n>zLWOD1*UAQ;ioJOASj06vPs z*_(i+<*oh>N4{J~`{0`{d6HJOLZd*eRW@%3bT(G39IX|Z1;XU*nqIf~XQYA=N&lx; zD!JX_RNe)x;_m&=1w&Ruo2hyC;gl0Eib0Pgv(a=@se_W2+i29SuftD z54E1U9z6fRTiEz)@-Qx`sL)qpH!Hp_4@mk`PH#9-!?1NLQH<>il0SOvdc(LmSt-Z! zo1-;?&vLE#D>4IFhJ91)9y}=xC7R@d2hdRW)hn>KaxleD-#rxKyu!S?BhC(N6^9d9 z-BI2)3VS>$j|nvFoL;A4f}590c~EN72lnu}AzkTo582y&#bL%2;ckPH$Tq?C*Q}Xn zdiH({eaG((#uRfAIlv_4y<_%kTAZla0`|$r?{e8*5b0pwB!T|N^k@mVTUj&$?d^t} vZOsmtIPdqJ-`zjT|DnM5sKB9wZRX2b%@tzD>+Z_SYYMm?^F*?oL(~5Sd$_S{ diff --git a/SQCSim2021/media/textures/single_player.png b/SQCSim2021/media/textures/single_player.png index 40461fa924e1c8f5c075a34edb28f453b48440f9..f553d0888b324c3d85319a35b8284024c9c995c2 100644 GIT binary patch delta 2068 zcmV+v2UB7>fiEA%36`B@rQljU;72QUy$7Olk`S(Nc@V)Hbn6 znP4MmWi$Z`(MF6Zj9Q7Y5KQ|#_s!YozK`8K=gzsa_wM|EFr1xz`#EoB&&>VY1Ch}$ zfBIWrU%x3!uABNYCi3`e-P3IJX89q zLyens|6l9YOy1YH%8DhL&?F-tG9`n^1T%43Uc1&a@YgkllJ8q0!AyLr2O8RQyy9aa zIj%9+qZ;S=Mx(_m8mD=R%6`#ef4VU!l4!z`jPCfSyR{-}E$TU}F^qiAk_jf+Cku(D zT{RbbKCUs>KHdN4`ADP1etEs^MR=Z~vM)4_MR=kKNiw>_pX=6&s`21Ds4-H>1T#UR zXS+UCS1}tiTVHRHTKT`ZqWAx-?E2`hkBN}IN zHUO9|GV>IbjiJK7IFd|^xh-OVk%(&2Z@n7wGypj3E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++ b/SQCSim2021/mesh.cpp @@ -9,7 +9,7 @@ Mesh::~Mesh() { void Mesh::FlushMeshToVBO() { m_vertexBuffer.SetMeshData(m_vd, m_vcount); m_vcount = 0; - delete[] m_vd; + //delete[] m_vd; } void Mesh::FlushVBO() {