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;