diff --git a/src/entities/Camera.cpp b/src/entities/Camera.cpp index 921ba0a..efbea7a 100644 --- a/src/entities/Camera.cpp +++ b/src/entities/Camera.cpp @@ -1,4 +1,6 @@ #include "camera.h" +#include +#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"; } } diff --git a/src/entities/main_character.cpp b/src/entities/main_character.cpp index 3a3e2c6..f123f24 100644 --- a/src/entities/main_character.cpp +++ b/src/entities/main_character.cpp @@ -15,7 +15,7 @@ namespace entities glm::vec3 main_character::move(GLFWwindow* window) { float movement_speed = -1.0f; - float up_down_speed = -0.4f; + float up_down_speed = -0.2f; float side_speed = 0; if (glfwGetKey(window, GLFW_KEY_W) == GLFW_PRESS) @@ -47,6 +47,11 @@ namespace entities up_down_speed -= UP_SPEED; } IncreasePosition(glm::vec3(side_speed, up_down_speed, movement_speed)); + if (position.x > 190) position.x = 190; + else if (position.x < -190) position.x = -190; + if (position.y > 350) position.y = 350; + else if (position.y < -40) position.y = -40; + MoveCollisionBox(); return glm::vec3(side_speed, up_down_speed, movement_speed ); } } diff --git a/src/entities/main_character.h b/src/entities/main_character.h index 9357e28..7d7f9af 100644 --- a/src/entities/main_character.h +++ b/src/entities/main_character.h @@ -7,7 +7,7 @@ namespace entities { class main_character : public CollisionEntity { const float SPEED = 1.0f; - const float UP_SPEED = 1.0f; + const float UP_SPEED = 0.6f; public: main_character(const models::TexturedModel& model, const glm::vec3& position, const glm::vec3& rotation, float scale, const collision::Box& bounding_box); diff --git a/src/scenes/in_Game_Scene.cpp b/src/scenes/in_Game_Scene.cpp index d149120..b9052b2 100644 --- a/src/scenes/in_Game_Scene.cpp +++ b/src/scenes/in_Game_Scene.cpp @@ -28,7 +28,7 @@ namespace scene models::ModelTexture texture; shaders::EntityShader* shader; shaders::GuiShader* gui_shader; - entities::Camera camera(glm::vec3(0, 100, 0), glm::vec3(0, 0, 0)); + entities::Camera camera(glm::vec3(0, 0, 0), glm::vec3(0, 0, 0)); std::vector guis; models::TexturedModel model; diff --git a/src/toolbox/toolbox.cpp b/src/toolbox/toolbox.cpp index 57473a9..dbfc3dc 100644 --- a/src/toolbox/toolbox.cpp +++ b/src/toolbox/toolbox.cpp @@ -31,4 +31,17 @@ namespace toolbox matrix = glm::translate(matrix, negative_cam_pos); return matrix; } + float Lerp(float from, float to, float amount) + { + return from + amount * (to - from); + } + + glm::vec3 Lerp(glm::vec3 from, glm::vec3 to, float amount) + { + glm::vec3 final; + final.x = Lerp(from.x, to.x, amount); + final.y = Lerp(from.y, to.y, amount); + final.z = Lerp(from.z, to.z, amount); + return final; + } } diff --git a/src/toolbox/toolbox.h b/src/toolbox/toolbox.h index f8bcef6..585c403 100644 --- a/src/toolbox/toolbox.h +++ b/src/toolbox/toolbox.h @@ -46,4 +46,8 @@ namespace toolbox * @return: The view matrix */ glm::mat4 CreateViewMatrix(entities::Camera& camera); + + float Lerp(float from, float to, float amount); + + glm::vec3 Lerp(glm::vec3 from, glm::vec3 to, float amount); }