yupplemayham/YuppleMayham/include/gameplay/camera.h

44 lines
No EOL
1.1 KiB
C++

#ifndef _H_CAMERA_H
#define _H_CAMERA_H
#include "gameplay/entity.h"
class Camera
{
public:
Camera(float viewPortW, float viewPortH) :
position(glm::vec3(0.0f, 0.0f, 0.0f)),
front(glm::vec3(0.0f, 0.0f, -1.0f)),
up(glm::vec3(0.0f, 1.0f, 0.0f)),
viewPortW(viewPortW),
viewPortH(viewPortH)
{};
void setPosition(const glm::vec3& position) { this->position = position; }
const Entity* getTarget() const { return target; }
const glm::vec3 getCenterPos() const { return glm::vec3(position.x + (viewPortW / 2.f), position.y + (viewPortH / 2.f), 0.0f); }
void setTarget(Entity* target) { this->target = target; }
void unsetTarget() { target = nullptr; }
bool isTargeting() { return (target != nullptr); }
void update(double deltaTime);
const glm::vec3 worldToLocal(const glm::vec3& worldCoordinates);
glm::mat4 getViewMatrix();
glm::mat4 getProjectionMatrix();
const glm::vec3 getPosition() const { return position; }
private:
Entity* target = nullptr;
glm::vec3 position;
glm::vec3 front;
glm::vec3 up;
float viewPortW, viewPortH;
float speed = 300.0f;
};
#endif // _H_CAMERA_H