Correction pour pouvoir tomber partout en dehors du monde
This commit is contained in:
parent
78903ecb06
commit
6b87156ff7
@ -1,4 +1,5 @@
|
|||||||
#include "chunk.h"
|
#include "chunk.h"
|
||||||
|
#include "world.h"
|
||||||
|
|
||||||
Chunk::Chunk(int x, int y) : m_posX(x), m_posY(y) { m_blocks.Reset(BTYPE_AIR); }
|
Chunk::Chunk(int x, int y) : m_posX(x), m_posY(y) { m_blocks.Reset(BTYPE_AIR); }
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
#include "array2d.h"
|
#include "array2d.h"
|
||||||
#include "vertexbuffer.h"
|
#include "vertexbuffer.h"
|
||||||
#include "blockinfo.h"
|
#include "blockinfo.h"
|
||||||
#include "world.h"
|
//#include "world.h"
|
||||||
|
|
||||||
class World;
|
class World;
|
||||||
|
|
||||||
|
@ -249,7 +249,7 @@ void Engine::Render(float elapsedTime) {
|
|||||||
all.Use();
|
all.Use();
|
||||||
if (m_world.GetChunks().Get(chx, chy)->IsDirty())
|
if (m_world.GetChunks().Get(chx, chy)->IsDirty())
|
||||||
m_world.GetChunks().Get(chx, chy)->Update(m_blockinfo, &m_world);
|
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();
|
m_world.GetChunks().Get(chx, chy)->Render();
|
||||||
all.ApplyTranslation(-chx * CHUNK_SIZE_X, 0, -chy * CHUNK_SIZE_Z);
|
all.ApplyTranslation(-chx * CHUNK_SIZE_X, 0, -chy * CHUNK_SIZE_Z);
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,8 @@ private:
|
|||||||
Shader m_shader01;
|
Shader m_shader01;
|
||||||
Audio m_audio = Audio(AUDIO_PATH "music01.wav");
|
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_keyW = false;
|
||||||
bool m_keyA = false;
|
bool m_keyA = false;
|
||||||
|
@ -10,10 +10,8 @@ Chunk* World::ChunkAt(float x, float y, float z) const {
|
|||||||
int cx = (int)x / CHUNK_SIZE_X;
|
int cx = (int)x / CHUNK_SIZE_X;
|
||||||
int cz = (int)z / CHUNK_SIZE_Z;
|
int cz = (int)z / CHUNK_SIZE_Z;
|
||||||
|
|
||||||
if (cx >= VIEW_DISTANCE || // L'array en ce moment est de VIEW_DISTANCE par VIEW_DISTANCE.
|
if (x < 0 || y < 0 || z < 0 ||
|
||||||
cz >= VIEW_DISTANCE ||
|
cx >= VIEW_DISTANCE || cz >= VIEW_DISTANCE || y >= CHUNK_SIZE_Y) return 0;
|
||||||
cx < 0 || cz < 0)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return m_chunks.Get(cx, cz);
|
return m_chunks.Get(cx, cz);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user