rétrécissement du monde

This commit is contained in:
Jonathan Trottier
2023-11-08 10:32:16 -05:00
parent 79013fe5d1
commit 80a5bf90b4
4 changed files with 33 additions and 1 deletions

View File

@@ -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);