mirror of
https://github.com/zhenyan121/Cubed.git
synced 2026-04-10 06:14:07 +08:00
feat: move players to world instead of main
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
#include <Cubed/config.hpp>
|
||||
|
||||
#include <string>
|
||||
struct MoveState {
|
||||
bool forward = false;
|
||||
bool back = false;
|
||||
@@ -11,12 +13,11 @@ struct MoveState {
|
||||
bool up = false;
|
||||
};
|
||||
|
||||
class World;
|
||||
|
||||
class Player {
|
||||
private:
|
||||
|
||||
bool** m_block_present;
|
||||
|
||||
float m_yaw;
|
||||
float m_pitch;
|
||||
|
||||
@@ -29,14 +30,17 @@ private:
|
||||
glm::vec3 m_right;
|
||||
MoveState m_move_state;
|
||||
|
||||
std::string m_name;
|
||||
const World& m_world;
|
||||
|
||||
|
||||
public:
|
||||
Player();
|
||||
Player(const World& world, const std::string& name);
|
||||
|
||||
const glm::vec3& get_front() const;
|
||||
const glm::vec3& get_player_pos() const;
|
||||
const MoveState& get_move_state() const;
|
||||
|
||||
void init(bool** block_present);
|
||||
void set_player_pos(const glm::vec3& pos);
|
||||
void update(float delta_time);
|
||||
void update_front_vec(float offset_x, float offset_y);
|
||||
|
||||
@@ -3,22 +3,23 @@
|
||||
|
||||
#include <Cubed/gameplay/chunk.hpp>
|
||||
|
||||
|
||||
class Player;
|
||||
|
||||
class World {
|
||||
private:
|
||||
BlockRenderData m_block_render_data;
|
||||
std::unordered_map<ChunkPos , Chunk, ChunkPos::Hash> m_chunks;
|
||||
|
||||
std::unordered_map<std::size_t, Player> m_players;
|
||||
public:
|
||||
|
||||
World();
|
||||
~World();
|
||||
|
||||
const BlockRenderData& get_block_render_data(int x, int y ,int z);
|
||||
Player& get_player(const std::string& name);
|
||||
void init_world();
|
||||
void render();
|
||||
|
||||
void update(float delta_time);
|
||||
|
||||
|
||||
};
|
||||
@@ -3,7 +3,7 @@
|
||||
namespace Assert {
|
||||
inline void msg(const char* condition, const char* file,
|
||||
int line, const char* func,
|
||||
const std::string& message
|
||||
const std::string& message = ""
|
||||
) {
|
||||
|
||||
LOG::error("Assertion failed: {} at {}: {} in function {}",
|
||||
|
||||
Reference in New Issue
Block a user