#include "CameraComponent.hpp"
#include "GameObject.hpp"
#include "Transform.hpp"
#include "SceneManager.h"

CameraComponent::CameraComponent(GameObject* gameObject) : Behaviour(gameObject)
{
	offset = SceneManager::GetInstance()->windowSize;
	if (SceneManager::GetInstance()->isFullscreen == true)
	{
		offset.x = offset.x / 12;
		offset.y = offset.y / 3;
	}
	else
	{
		offset.x = offset.x / 6;
		offset.y = offset.y / 3;
	}
}

void CameraComponent::Update(float deltaTime) {
	auto transform = gameObject.GetTransform();
	auto playerPosition = player->GetTransform()->GetPosition();
	//transform->SetPosition(glm::vec2(playerPosition.x + offset.x, offset.y));
	transform->SetPosition(glm::vec2(playerPosition.x + offset.x, playerPosition.y));
	auto position = transform->GetPosition();
	
	glm::vec3 eye(position, 0);
	glm::vec3 at(position, -1);
	glm::vec3 up(0, 1, 0);
	camera.lookAt(eye, at, up);
	pos += 0.1f;
	
}

void CameraComponent::InitialiseSelf()
{
}

void CameraComponent::Initialise()
{
}

