Test monde infini

This commit is contained in:
MarcEricMartel
2021-12-02 18:12:35 -05:00
parent 2ad6b7e2c6
commit 033f69465c
159 changed files with 332 additions and 327 deletions

View File

@@ -6,6 +6,9 @@
#include "vector3.h"
#include "player.h"
#include "transformation.h"
#include "perlin.h"
#include "shader.h"
#include "textureatlas.h"
#include <fstream>
#include <string>
#include <vector>
@@ -14,27 +17,38 @@ class Chunk;
class Player;
class World {
public:
World();
~World();
public:
World();
~World();
Array2d<Chunk*>& GetChunks();
Array2d<Chunk*>& GetChunks();
Chunk* ChunkAt(float x, float y, float z) const;
Chunk* ChunkAt(const Vector3f& pos) const;
BlockType BlockAt(float x, float y, float z, BlockType defaultBlockType = BTYPE_AIR) const;
BlockType BlockAt(const Vector3f& pos, BlockType defaultBlockType = BTYPE_AIR) const;
Chunk* ChunkAt(float x, float y, float z) const;
Chunk* ChunkAt(const Vector3f& pos) const;
void TransposeWorld(Player& player);
void CleanUpWorld(int& frames);
Chunk* RetrieveChunk(int x, int y);
BlockType BlockAt(float x, float y, float z, BlockType defaultBlockType = BTYPE_AIR) const;
BlockType BlockAt(const Vector3f& pos, BlockType defaultBlockType = BTYPE_AIR) const;
void Update(int& rendercount, int& badhitcount, Player& player, Transformation& world, Shader& shader, TextureAtlas& atlas, Perlin& perlin, BlockInfo* blockinfo[BTYPE_LAST]);
void GetScope(int& x, int& y);
void ChangeBlockAtCursor(BlockType blockType, Player& player, bool& block);
void CleanUpWorld(int& deleteframes, bool clear);
private:
Array2d<Chunk*> m_chunks = Array2d<Chunk*>(WORLD_SIZE_X, WORLD_SIZE_Y);
std::vector<Chunk*> m_tbDeleted;
int m_center[2] = {INT16_MAX / 2 - WORLD_SIZE_X / 2, INT16_MAX / 2 - WORLD_SIZE_Y / 2};
int m_center[2] = { INT16_MAX / 2 - WORLD_SIZE_X / 2, INT16_MAX / 2 - WORLD_SIZE_Y / 2 };
bool GenerateChunk(int x, int y, Perlin& perlin);
void UpdateChunk(int& generates, int& updates, int chx, int chy, Perlin& perlin, BlockInfo* blockinfo[BTYPE_LAST]);
void RenderWorld(int& rendercount, int& badhitcount, Player& player, Transformation& world, Shader& shader);
void UpdateWorld(Player& player, Perlin& perlin, BlockInfo* blockinfo[BTYPE_LAST]);
void TransposeWorld(Player& player);
Chunk* RetrieveChunk(int x, int y);
};
#endif // WORLD_H__