From 6b87156ff7231d9dd304f99e09f795dc5bdcbb73 Mon Sep 17 00:00:00 2001 From: MarcEricMartel <74071476+MarcEricMartel@users.noreply.github.com> Date: Fri, 19 Nov 2021 09:05:28 -0500 Subject: [PATCH] Correction pour pouvoir tomber partout en dehors du monde --- SQCSim2021/chunk.cpp | 1 + SQCSim2021/chunk.h | 2 +- SQCSim2021/engine.cpp | 2 +- SQCSim2021/engine.h | 3 ++- SQCSim2021/world.cpp | 6 ++---- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/SQCSim2021/chunk.cpp b/SQCSim2021/chunk.cpp index 606b97f..a732f85 100644 --- a/SQCSim2021/chunk.cpp +++ b/SQCSim2021/chunk.cpp @@ -1,4 +1,5 @@ #include "chunk.h" +#include "world.h" Chunk::Chunk(int x, int y) : m_posX(x), m_posY(y) { m_blocks.Reset(BTYPE_AIR); } diff --git a/SQCSim2021/chunk.h b/SQCSim2021/chunk.h index 62ea548..f53c57f 100644 --- a/SQCSim2021/chunk.h +++ b/SQCSim2021/chunk.h @@ -5,7 +5,7 @@ #include "array2d.h" #include "vertexbuffer.h" #include "blockinfo.h" -#include "world.h" +//#include "world.h" class World; diff --git a/SQCSim2021/engine.cpp b/SQCSim2021/engine.cpp index d2ef226..da4b34d 100644 --- a/SQCSim2021/engine.cpp +++ b/SQCSim2021/engine.cpp @@ -249,7 +249,7 @@ void Engine::Render(float elapsedTime) { all.Use(); if (m_world.GetChunks().Get(chx, chy)->IsDirty()) m_world.GetChunks().Get(chx, chy)->Update(m_blockinfo, &m_world); - + //if (chx * CHUNK_SIZE_X >= m_player.GetPosition().x * m_player.GetDirection().x && chy * CHUNK_SIZE_Z >= m_player.GetPosition().z * m_player.GetDirection().z) m_world.GetChunks().Get(chx, chy)->Render(); all.ApplyTranslation(-chx * CHUNK_SIZE_X, 0, -chy * CHUNK_SIZE_Z); } diff --git a/SQCSim2021/engine.h b/SQCSim2021/engine.h index 0533c3f..cc4fbc6 100644 --- a/SQCSim2021/engine.h +++ b/SQCSim2021/engine.h @@ -51,7 +51,8 @@ private: Shader m_shader01; Audio m_audio = Audio(AUDIO_PATH "music01.wav"); - Player m_player = Player(Vector3f(VIEW_DISTANCE * CHUNK_SIZE_X / 2, CHUNK_SIZE_Y / 2, VIEW_DISTANCE * CHUNK_SIZE_Z / 2)); + //Player m_player = Player(Vector3f(VIEW_DISTANCE * CHUNK_SIZE_X / 2, CHUNK_SIZE_Y / 2, VIEW_DISTANCE * CHUNK_SIZE_Z / 2)); + Player m_player = Player(Vector3f(1, CHUNK_SIZE_Y / 2, 1)); bool m_keyW = false; bool m_keyA = false; diff --git a/SQCSim2021/world.cpp b/SQCSim2021/world.cpp index 22eda96..0749d5c 100644 --- a/SQCSim2021/world.cpp +++ b/SQCSim2021/world.cpp @@ -10,10 +10,8 @@ Chunk* World::ChunkAt(float x, float y, float z) const { int cx = (int)x / CHUNK_SIZE_X; int cz = (int)z / CHUNK_SIZE_Z; - if (cx >= VIEW_DISTANCE || // L'array en ce moment est de VIEW_DISTANCE par VIEW_DISTANCE. - cz >= VIEW_DISTANCE || - cx < 0 || cz < 0) - return 0; + if (x < 0 || y < 0 || z < 0 || + cx >= VIEW_DISTANCE || cz >= VIEW_DISTANCE || y >= CHUNK_SIZE_Y) return 0; return m_chunks.Get(cx, cz); }