[ADD] camera follows the only at the z position

This commit is contained in:
Nathalie Seen
2021-06-04 14:44:41 +02:00
parent 2523e1abfa
commit 86383aace5
5 changed files with 34 additions and 8 deletions

View File

@@ -7,6 +7,10 @@ namespace entities
rotation(rotation)
{}
void Camera::Follow(glm::vec3 follow_position) {
position.z = follow_position.z + 200;
}
void Camera::Move(GLFWwindow* window)
{
float movement_speed = 0;

View File

@@ -28,6 +28,8 @@ namespace entities
* @param window: The OpenGL window
*/
void Move(GLFWwindow* window);
void Follow(glm::vec3 follow_position);
inline glm::vec3 GetPosition() const{ return position; }
inline glm::vec3 GetRotation() const{ return rotation; }

View File

@@ -14,8 +14,8 @@ namespace entities
}
glm::vec3 main_character::move(GLFWwindow* window)
{
float movement_speed = 0;
float up_down_speed = 0;
float movement_speed = -1.0f;
float up_down_speed = -0.4f;
float side_speed = 0;
if (glfwGetKey(window, GLFW_KEY_W) == GLFW_PRESS)
@@ -42,6 +42,10 @@ namespace entities
{
up_down_speed += UP_SPEED;
}
if (glfwGetKey(window, GLFW_KEY_LEFT_SHIFT) == GLFW_PRESS)
{
up_down_speed -= UP_SPEED;
}
IncreasePosition(glm::vec3(side_speed, up_down_speed, movement_speed));
return glm::vec3(side_speed, up_down_speed, movement_speed );
}

View File

@@ -5,9 +5,8 @@
namespace entities
{
class main_character : public CollisionEntity {
const int SPEED = 10;
const float SPEED = 1.0f;
const float UP_SPEED = 1.0f;
public:
main_character(const models::TexturedModel& model, const glm::vec3& position,