change WorldRenderer to class
This commit is contained in:
@@ -10,7 +10,8 @@ namespace game {
|
||||
enum class GameState : std::uint8_t{
|
||||
Lobby,
|
||||
Game,
|
||||
EndGame
|
||||
EndGame,
|
||||
Disconnected,
|
||||
};
|
||||
|
||||
typedef std::map<std::uint8_t, Player> PlayerList;
|
||||
|
||||
@@ -22,6 +22,8 @@ public:
|
||||
|
||||
void tick(std::uint64_t delta);
|
||||
|
||||
void render();
|
||||
|
||||
void connect(const std::string& address, std::uint16_t port);
|
||||
void closeConnection();
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "game/BaseGame.h"
|
||||
#include "protocol/PacketHandler.h"
|
||||
#include "WorldClient.h"
|
||||
#include "render/WorldRenderer.h"
|
||||
|
||||
namespace td {
|
||||
namespace client {
|
||||
@@ -13,12 +14,15 @@ private:
|
||||
std::uint32_t m_LobbyTime = 0;
|
||||
game::Player* m_Player = nullptr;
|
||||
client::WorldClient m_WorldClient{this};
|
||||
render::WorldRenderer m_WorldRenderer{&m_WorldClient};
|
||||
public:
|
||||
ClientGame(protocol::PacketDispatcher* dispatcher);
|
||||
virtual ~ClientGame();
|
||||
|
||||
virtual void tick(std::uint64_t delta);
|
||||
|
||||
void renderWorld();
|
||||
|
||||
std::uint32_t getLobbyTime() const{return m_LobbyTime;}
|
||||
const game::Player* getPlayer() const{return m_Player;}
|
||||
|
||||
@@ -30,6 +34,8 @@ public:
|
||||
virtual void HandlePacket(protocol::UpdateGameStatePacket* packet);
|
||||
virtual void HandlePacket(protocol::UpdateLobbyTimePacket* packet);
|
||||
virtual void HandlePacket(protocol::UpdateMoneyPacket* packet);
|
||||
virtual void HandlePacket(protocol::DisconnectPacket* packet);
|
||||
virtual void HandlePacket(protocol::WorldDataPacket* packet);
|
||||
};
|
||||
|
||||
} // namespace client
|
||||
|
||||
@@ -1,23 +1,39 @@
|
||||
#pragma once
|
||||
|
||||
#include "game/World.h"
|
||||
#include "render/loader/GLLoader.h"
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
namespace td {
|
||||
namespace render {
|
||||
|
||||
namespace WorldRenderer{
|
||||
class WorldRenderer{
|
||||
private:
|
||||
game::World* m_World;
|
||||
std::unique_ptr<GL::VAO> m_WorldVao, m_MobVao;
|
||||
glm::vec2 m_CamPos;
|
||||
float m_Zoom = 1;
|
||||
float m_CamSensibility = 1;
|
||||
public:
|
||||
WorldRenderer(game::World* world);
|
||||
~WorldRenderer();
|
||||
|
||||
void init(const game::World* world);
|
||||
void update();
|
||||
void render();
|
||||
void destroy();
|
||||
void loadModels();
|
||||
|
||||
void moveCam(float relativeX, float relativeY, float aspectRatio);
|
||||
void changeZoom(float zoom);
|
||||
void click(int mouseX, int mouseY);
|
||||
|
||||
} // namespace WorldRenderer
|
||||
void update();
|
||||
void render() const;
|
||||
|
||||
void setCamPos(float camX, float camY);
|
||||
|
||||
void moveCam(float relativeX, float relativeY, float aspectRatio);
|
||||
void changeZoom(float zoom);
|
||||
void click(int mouseX, int mouseY);
|
||||
private:
|
||||
void renderWorld() const;
|
||||
void renderTowers() const;
|
||||
void renderMobs() const;
|
||||
};
|
||||
|
||||
} // namespace render
|
||||
} // namespace td
|
||||
|
||||
Reference in New Issue
Block a user