BROKE BUILD: entity system lol time to dieee
This commit is contained in:
@@ -1,3 +1,19 @@
|
||||
#include "entity.hpp"
|
||||
|
||||
#include "../renderer/camera.hpp"
|
||||
|
||||
Entity::Entity(glm::vec3 postion, glm::vec3 direction, std::shared_ptr<Camera> camera)
|
||||
: Position(Position)
|
||||
, Direction(direction)
|
||||
, EntityCamera(camera)
|
||||
{
|
||||
|
||||
if (EntityCamera) {
|
||||
EntityCamera->UpdateView();
|
||||
}
|
||||
}
|
||||
|
||||
Player::Player {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -3,27 +3,49 @@
|
||||
|
||||
#include "../common.hpp"
|
||||
|
||||
class Camera;
|
||||
|
||||
class Entity {
|
||||
public:
|
||||
|
||||
Entity();
|
||||
Entity(glm::vec3 position, glm::vec3 direction = { 0.0f, 0.0f, 0.0f }, std::shared_ptr<Camera> camera = std::make_shared<Camera>());
|
||||
|
||||
// World position
|
||||
bool Player = false;
|
||||
|
||||
// World position, 1.7 units below the
|
||||
// camera position.
|
||||
glm::vec3 Position;
|
||||
// Look direction
|
||||
// Look direction of the camera
|
||||
glm::vec3 Direction;
|
||||
|
||||
// Velocity in direction
|
||||
// of movement
|
||||
glm::vec3 Velocity;
|
||||
|
||||
// Can be null
|
||||
std::shared_ptr<Camera> EntityCamera;
|
||||
|
||||
// Collider
|
||||
|
||||
|
||||
// Mesh (or reference to)
|
||||
|
||||
};
|
||||
|
||||
|
||||
class Player : public Entity {
|
||||
public:
|
||||
|
||||
Player(glm::vec3 position, glm::vec3 direction = {0.0f, 0.0f, 0.0f});
|
||||
|
||||
void Move(Uint8* state);
|
||||
void HandleMouse(SDL_Event e);
|
||||
|
||||
void UpdatePosition(glm::vec3 position);
|
||||
void UpdateDirection(glm::vec3 direction);
|
||||
|
||||
void CameaUpdateProjection(int xres, int yres);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -4,9 +4,11 @@
|
||||
|
||||
#include "../renderer/shader.hpp"
|
||||
|
||||
#include "../config.hpp"
|
||||
#include "../util/fastnoise.hpp"
|
||||
|
||||
#include "../config.hpp"
|
||||
#include "entity.hpp"
|
||||
|
||||
World::World() {
|
||||
|
||||
}
|
||||
@@ -87,7 +89,11 @@ std::vector<std::shared_ptr<Chunk>> World::GetRenderableChunks() {
|
||||
|
||||
}
|
||||
|
||||
void World::Render(std::shared_ptr<Camera> camera) {
|
||||
void World::Update(std::shared_ptr<Entity> player) {
|
||||
|
||||
}
|
||||
|
||||
void World::Render(std::shared_ptr<Entity> player) {
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D_ARRAY, m_textureMapID);
|
||||
|
||||
@@ -96,7 +102,7 @@ void World::Render(std::shared_ptr<Camera> camera) {
|
||||
|
||||
for (int i = 0; i < chunks.size(); i++) {
|
||||
|
||||
chunks[i]->Render(camera, m_shaders["Basic"]);
|
||||
chunks[i]->Render(player->EntityCamera, m_shaders["Basic"]);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
class FastNoise;
|
||||
|
||||
class Shader;
|
||||
class Entity;
|
||||
|
||||
class World {
|
||||
public:
|
||||
@@ -33,8 +34,8 @@ public:
|
||||
|
||||
std::vector<std::shared_ptr<Chunk>> GetRenderableChunks();
|
||||
|
||||
|
||||
void Render(std::shared_ptr<Camera> camera);
|
||||
void Update(std::shared_ptr<Entity> player);
|
||||
void Render(std::shared_ptr<Entity> player);
|
||||
|
||||
~World();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user