From b1e420f564ce89a46b8ef757a6c75c0e9e6af7a4 Mon Sep 17 00:00:00 2001 From: EmaMaker Date: Thu, 23 Feb 2023 19:07:17 +0100 Subject: [PATCH] camera: allow to strafe up and down --- include/camera.hpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/include/camera.hpp b/include/camera.hpp index 2cabbaf..17f16c2 100644 --- a/include/camera.hpp +++ b/include/camera.hpp @@ -32,6 +32,12 @@ public: this->cameraPos -= glm::normalize(glm::cross(cameraFront, cameraUp)) * cameraSpeed; if (glfwGetKey(window, GLFW_KEY_D) == GLFW_PRESS) this->cameraPos += glm::normalize(glm::cross(cameraFront, cameraUp)) * cameraSpeed; + + if (glfwGetKey(window, GLFW_KEY_Q) == GLFW_PRESS) + this->cameraPos += cameraSpeed * cameraUp; + if (glfwGetKey(window, GLFW_KEY_Z) == GLFW_PRESS) + this->cameraPos -= cameraSpeed * cameraUp; + direction.x = cos(glm::radians(yaw)) * cos(glm::radians(pitch)); direction.y = sin(glm::radians(pitch)); @@ -92,7 +98,7 @@ public: } private: - glm::vec3 cameraPos = glm::vec3(static_cast(CHUNK_SIZE)*24, 80.0f, static_cast(CHUNK_SIZE)*24); + glm::vec3 cameraPos = glm::vec3(static_cast(CHUNK_SIZE)*24, 40.0f, static_cast(CHUNK_SIZE)*24); glm::vec3 cameraFront = glm::vec3(0.0f, 0.0f, -1.0f); glm::vec3 cameraUp = glm::vec3(0.0f, 1.0f, 0.0f); glm::vec3 direction = glm::vec3(0.0f);