From 85f4f82660a623f48a335017917444152850a52c Mon Sep 17 00:00:00 2001 From: Rynort Date: Mon, 23 Oct 2023 17:51:29 -0400 Subject: [PATCH 1/4] avancement menu pause --- SQCSim2021/engine.cpp | 41 ++++++++++++++++++++++++++++++++++++++--- SQCSim2021/engine.h | 3 ++- 2 files changed, 40 insertions(+), 4 deletions(-) diff --git a/SQCSim2021/engine.cpp b/SQCSim2021/engine.cpp index a5939e6..ee279dd 100644 --- a/SQCSim2021/engine.cpp +++ b/SQCSim2021/engine.cpp @@ -222,6 +222,37 @@ 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(); + + MenuBGTexture.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(); +} + void Engine::Init() { GLenum glewErr = glewInit(); if (glewErr != GLEW_OK) { @@ -684,11 +715,11 @@ void Engine::Render(float elapsedTime) { if (leftright) vstep = Vector3f(m_player.GetPosition().x + m_player.GetDirection().z, m_player.GetPosition().y - 1.7f, m_player.GetPosition().z + m_player.GetDirection().x); else vstep = Vector3f(m_player.GetPosition().x - m_player.GetDirection().z, m_player.GetPosition().y - 1.7f, m_player.GetPosition().z - m_player.GetDirection().x); - m_audio.Create3DAudioObj(step, AUDIO_PATH "step.wav", vstep, m_player.GetVelocity(), .8f); + m_audio.Create3DAudioObj(step, AUDIO_PATH "step.wav", vstep, m_player.GetVelocity(), .8f, false); leftright = !leftright; break; case Player::Sound::FALL: - m_audio.Create3DAudioObj(step, AUDIO_PATH "hit.wav", m_player.GetPosition(), m_player.GetVelocity(), 1.f); + m_audio.Create3DAudioObj(step, AUDIO_PATH "hit.wav", m_player.GetPosition(), m_player.GetVelocity(), 1.f, false); break; default: break; } @@ -755,7 +786,7 @@ void Engine::Render(float elapsedTime) { static bool fell = false; if (m_player.GetPosition().y < 1.7f && !fell) { - m_audio.Create3DAudioObj(m_scream, AUDIO_PATH "scream.wav", m_player.GetPOV(), m_player.GetVelocity(), 1.f); + m_audio.Create3DAudioObj(m_scream, AUDIO_PATH "scream.wav", m_player.GetPOV(), m_player.GetVelocity(), 1.f, false); fell = true; } else if (m_player.GetPosition().y < -20.f) { @@ -767,6 +798,10 @@ void Engine::Render(float elapsedTime) { else if (m_gamestate == GameState::MAIN_MENU || m_gamestate == GameState::OPTIONS) { DrawMenu(); + } + else if (m_gamestate == GameState::PAUSE) + { + } else if (m_gamestate == GameState::QUIT) Stop(); diff --git a/SQCSim2021/engine.h b/SQCSim2021/engine.h index 57b4e2e..07e1211 100644 --- a/SQCSim2021/engine.h +++ b/SQCSim2021/engine.h @@ -25,6 +25,7 @@ public: Engine(); virtual ~Engine(); virtual void DrawMenu(); + virtual void DrawPause(); virtual void Init(); virtual void DeInit(); virtual void LoadResource(); @@ -80,7 +81,7 @@ private: Bullet* m_bullets[MAX_BULLETS]; //Menu - enum class GameState { MAIN_MENU, OPTIONS, QUIT, NEWG, PLAY }; + enum class GameState { MAIN_MENU, OPTIONS, QUIT, NEWG, PLAY, PAUSE }; GameState m_gamestate = GameState::MAIN_MENU; Texture MenuTitleTexture; Texture MenuBGTexture; From e5189f437c88a3c76737328e65cfc48d13d8379a Mon Sep 17 00:00:00 2001 From: Rynort Date: Mon, 30 Oct 2023 15:49:17 -0400 Subject: [PATCH 2/4] 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; From cd921b3ab336609083edf5325086f255497d7898 Mon Sep 17 00:00:00 2001 From: Rynort Date: Mon, 6 Nov 2023 16:04:34 -0500 Subject: [PATCH 3/4] =?UTF-8?q?R=C3=A9paration=20du=20Merge=20du=20Pause?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SQCSim2021/engine.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/SQCSim2021/engine.cpp b/SQCSim2021/engine.cpp index e80127f..9205360 100644 --- a/SQCSim2021/engine.cpp +++ b/SQCSim2021/engine.cpp @@ -429,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"); From 80a5bf90b4ff6e84d6897a4449bd58e036f43de4 Mon Sep 17 00:00:00 2001 From: Jonathan Trottier Date: Wed, 8 Nov 2023 10:32:16 -0500 Subject: [PATCH 4/4] =?UTF-8?q?r=C3=A9tr=C3=A9cissement=20du=20monde?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SQCSim-common/world.cpp | 21 +++++++++++++++++++++ SQCSim-common/world.h | 2 ++ SQCSim2021/engine.cpp | 9 ++++++++- SQCSim2021/engine.h | 2 ++ 4 files changed, 33 insertions(+), 1 deletion(-) diff --git a/SQCSim-common/world.cpp b/SQCSim-common/world.cpp index c18c32c..a803e01 100644 --- a/SQCSim-common/world.cpp +++ b/SQCSim-common/world.cpp @@ -16,6 +16,9 @@ void World::SetSeed(uint64_t seed) { m_seed = seed; } + + + Chunk* World::ChunkAt(float x, float y, float z) const { int cx = (int)x / CHUNK_SIZE_X; int cz = (int)z / CHUNK_SIZE_Z; @@ -31,6 +34,24 @@ Chunk* World::ChunkAt(float x, float y, float z) const { Chunk* World::ChunkAt(const Vector3f& pos) const { return ChunkAt(pos.x, pos.y, pos.z); } +void World::RemoveChunk(int nbReduit) +{ + for (int x = 0; x < WORLD_SIZE_X; ++x) + for (int y = 0; y < WORLD_SIZE_Y; ++y) + { + if (x < nbReduit) + m_chunks.Remove(x,y); + if (y < nbReduit) + m_chunks.Remove(x, y); + if (y > WORLD_SIZE_Y - nbReduit) + m_chunks.Remove(x, y); + if (x > WORLD_SIZE_X - nbReduit) + m_chunks.Remove(x, y); + } + + +} + BlockType World::BlockAt(float x, float y, float z, BlockType defaultBlockType) const { Chunk* c = ChunkAt(x, y, z); diff --git a/SQCSim-common/world.h b/SQCSim-common/world.h index 8a166af..e9b4840 100644 --- a/SQCSim-common/world.h +++ b/SQCSim-common/world.h @@ -28,6 +28,8 @@ public: Chunk* ChunkAt(float x, float y, float z) const; Chunk* ChunkAt(const Vector3f& pos) const; + void RemoveChunk(int nbReduit); + BlockType BlockAt(float x, float y, float z, BlockType defaultBlockType = BTYPE_AIR) const; BlockType BlockAt(const Vector3f& pos, BlockType defaultBlockType = BTYPE_AIR) const; diff --git a/SQCSim2021/engine.cpp b/SQCSim2021/engine.cpp index 76f379b..bc4b6b5 100644 --- a/SQCSim2021/engine.cpp +++ b/SQCSim2021/engine.cpp @@ -883,7 +883,11 @@ void Engine::DrawHud(float elapsedTime, BlockType bloc) { glPushMatrix(); int timer = GetCountdown(elapsedTime); - + for (int i = 1; i < WORLD_SIZE_X; i++) + { + if (timer <= COUNTDOWN - m_timerReductionChunk * i) + m_world.RemoveChunk(m_nbReductionChunk * i); + } if (m_keyK) { SystemNotification(m_messageNotification); m_keyK = false; @@ -953,6 +957,8 @@ int Engine::GetFps(float elapsedTime) const { return 1 / elapsedTime; } int Engine::GetCountdown(float elapsedTime) { if (m_resetcountdown) { + m_nbReductionChunk = 4; + m_timerReductionChunk = 30; m_countdown = m_time + COUNTDOWN; m_resetcountdown = false; } @@ -1081,6 +1087,7 @@ void Engine::Render(float elapsedTime) { m_world.Update(m_bullets, m_player.GetPosition(), m_blockinfo); m_renderer.UpdateMesh(&m_world, m_player.GetPosition(), m_blockinfo); + if (m_isSkybox) m_skybox.Render(skybox); DrawHud(elapsedTime, bloc); diff --git a/SQCSim2021/engine.h b/SQCSim2021/engine.h index d51d064..ab48557 100644 --- a/SQCSim2021/engine.h +++ b/SQCSim2021/engine.h @@ -109,6 +109,8 @@ private: int m_renderCount = 0; int m_countdown = COUNTDOWN; + int m_nbReductionChunk = 4; + int m_timerReductionChunk = 30; bool m_damage = false;