2014-12-18 07:02:48 +01:00
|
|
|
/*
|
|
|
|
* =====================================================================================
|
|
|
|
*
|
|
|
|
* Filename: World.hpp
|
|
|
|
*
|
2018-06-05 01:24:54 +02:00
|
|
|
* Description:
|
2014-12-18 07:02:48 +01:00
|
|
|
*
|
|
|
|
* Created: 16/12/2014 15:28:02
|
|
|
|
*
|
2018-06-12 09:24:43 +02:00
|
|
|
* Author: Quentin Bazin, <quent42340@gmail.com>
|
2014-12-18 07:02:48 +01:00
|
|
|
*
|
|
|
|
* =====================================================================================
|
|
|
|
*/
|
|
|
|
#ifndef WORLD_HPP_
|
|
|
|
#define WORLD_HPP_
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
#include "Chunk.hpp"
|
2018-06-14 22:11:25 +02:00
|
|
|
#include "IDrawable.hpp"
|
2018-06-12 23:08:42 +02:00
|
|
|
#include "TerrainGenerator.hpp"
|
2014-12-18 07:02:48 +01:00
|
|
|
|
2018-06-13 03:47:20 +02:00
|
|
|
class Camera;
|
|
|
|
|
2018-06-14 22:11:25 +02:00
|
|
|
class World : public IDrawable {
|
2014-12-18 07:02:48 +01:00
|
|
|
public:
|
|
|
|
World();
|
2018-06-05 01:24:54 +02:00
|
|
|
|
2018-06-28 09:58:37 +02:00
|
|
|
void update(Player &player);
|
2018-06-14 23:07:20 +02:00
|
|
|
|
2018-06-19 05:38:14 +02:00
|
|
|
Chunk *getChunk(int cx, int cy, int cz) const;
|
2018-06-05 01:24:54 +02:00
|
|
|
|
2018-06-23 23:05:36 +02:00
|
|
|
u32 getBlock(int x, int y, int z) const;
|
2018-06-14 01:42:54 +02:00
|
|
|
void setBlock(int x, int y, int z, u32 id);
|
2018-06-13 03:47:20 +02:00
|
|
|
|
2018-06-29 07:16:51 +02:00
|
|
|
BlockData *getBlockData(int x, int y, int z);
|
|
|
|
|
2014-12-23 16:15:44 +01:00
|
|
|
// Render distance in chunks
|
2015-02-06 01:44:16 +01:00
|
|
|
static const u16 renderDistance = 8;
|
2018-06-05 01:24:54 +02:00
|
|
|
|
2014-12-18 07:02:48 +01:00
|
|
|
private:
|
2018-06-14 22:11:25 +02:00
|
|
|
void draw(RenderTarget &target, RenderStates states) const override;
|
|
|
|
|
2018-06-19 05:38:14 +02:00
|
|
|
const s32 m_width = 32;
|
|
|
|
const s32 m_height = 4;
|
|
|
|
const s32 m_depth = 32;
|
2018-06-05 01:24:54 +02:00
|
|
|
|
2018-06-21 05:45:17 +02:00
|
|
|
Texture &m_texture;
|
2018-06-05 01:24:54 +02:00
|
|
|
|
2014-12-18 07:02:48 +01:00
|
|
|
std::vector<std::unique_ptr<Chunk>> m_chunks;
|
2018-06-12 23:08:42 +02:00
|
|
|
|
|
|
|
TerrainGenerator m_terrainGenerator;
|
2014-12-18 07:02:48 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // WORLD_HPP_
|