rétrécissement du monde
This commit is contained in:
parent
79013fe5d1
commit
80a5bf90b4
@ -16,6 +16,9 @@ void World::SetSeed(uint64_t seed) {
|
|||||||
m_seed = seed;
|
m_seed = seed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Chunk* World::ChunkAt(float x, float y, float z) const {
|
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;
|
||||||
@ -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); }
|
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 {
|
BlockType World::BlockAt(float x, float y, float z, BlockType defaultBlockType) const {
|
||||||
Chunk* c = ChunkAt(x, y, z);
|
Chunk* c = ChunkAt(x, y, z);
|
||||||
|
|
||||||
|
@ -28,6 +28,8 @@ public:
|
|||||||
Chunk* ChunkAt(float x, float y, float z) const;
|
Chunk* ChunkAt(float x, float y, float z) const;
|
||||||
Chunk* ChunkAt(const Vector3f& pos) 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(float x, float y, float z, BlockType defaultBlockType = BTYPE_AIR) const;
|
||||||
BlockType BlockAt(const Vector3f& pos, BlockType defaultBlockType = BTYPE_AIR) const;
|
BlockType BlockAt(const Vector3f& pos, BlockType defaultBlockType = BTYPE_AIR) const;
|
||||||
|
|
||||||
|
@ -883,7 +883,11 @@ void Engine::DrawHud(float elapsedTime, BlockType bloc) {
|
|||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
|
|
||||||
int timer = GetCountdown(elapsedTime);
|
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) {
|
if (m_keyK) {
|
||||||
SystemNotification(m_messageNotification);
|
SystemNotification(m_messageNotification);
|
||||||
m_keyK = false;
|
m_keyK = false;
|
||||||
@ -953,6 +957,8 @@ int Engine::GetFps(float elapsedTime) const { return 1 / elapsedTime; }
|
|||||||
int Engine::GetCountdown(float elapsedTime) {
|
int Engine::GetCountdown(float elapsedTime) {
|
||||||
if (m_resetcountdown)
|
if (m_resetcountdown)
|
||||||
{
|
{
|
||||||
|
m_nbReductionChunk = 4;
|
||||||
|
m_timerReductionChunk = 30;
|
||||||
m_countdown = m_time + COUNTDOWN;
|
m_countdown = m_time + COUNTDOWN;
|
||||||
m_resetcountdown = false;
|
m_resetcountdown = false;
|
||||||
}
|
}
|
||||||
@ -1081,6 +1087,7 @@ void Engine::Render(float elapsedTime) {
|
|||||||
m_world.Update(m_bullets, m_player.GetPosition(), m_blockinfo);
|
m_world.Update(m_bullets, m_player.GetPosition(), m_blockinfo);
|
||||||
m_renderer.UpdateMesh(&m_world, m_player.GetPosition(), m_blockinfo);
|
m_renderer.UpdateMesh(&m_world, m_player.GetPosition(), m_blockinfo);
|
||||||
|
|
||||||
|
|
||||||
if (m_isSkybox) m_skybox.Render(skybox);
|
if (m_isSkybox) m_skybox.Render(skybox);
|
||||||
|
|
||||||
DrawHud(elapsedTime, bloc);
|
DrawHud(elapsedTime, bloc);
|
||||||
|
@ -109,6 +109,8 @@ private:
|
|||||||
|
|
||||||
int m_renderCount = 0;
|
int m_renderCount = 0;
|
||||||
int m_countdown = COUNTDOWN;
|
int m_countdown = COUNTDOWN;
|
||||||
|
int m_nbReductionChunk = 4;
|
||||||
|
int m_timerReductionChunk = 30;
|
||||||
|
|
||||||
bool m_damage = false;
|
bool m_damage = false;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user