[ADD] made camera follow the character with lerp

This commit is contained in:
Nathalie Seen
2021-06-08 10:55:48 +02:00
parent 86383aace5
commit edbbfb136a
6 changed files with 35 additions and 4 deletions

View File

@@ -1,4 +1,6 @@
#include "camera.h"
#include <iostream>
#include "../toolbox/toolbox.h"
namespace entities
{
@@ -8,7 +10,9 @@ namespace entities
{}
void Camera::Follow(glm::vec3 follow_position) {
position.z = follow_position.z + 200;
follow_position.z += 100;
follow_position.y += 50;
position = toolbox::Lerp(position, follow_position, 0.1);
}
void Camera::Move(GLFWwindow* window)
@@ -41,9 +45,14 @@ namespace entities
{
up_down_speed += UP_SPEED;
}
if (glfwGetKey(window, GLFW_KEY_LEFT_SHIFT) == GLFW_PRESS)
{
up_down_speed -= UP_SPEED;
}
position.x += side_speed;
position.z += movement_speed;
position.y += up_down_speed;
std::cout <<"x= " << position.x <<"\ny= " << position.y << "\nz= " << position.z << "\n";
}
}