diff --git a/src/entities/Camera.cpp b/src/entities/Camera.cpp index eb4ecb4..d2b38cf 100644 --- a/src/entities/Camera.cpp +++ b/src/entities/Camera.cpp @@ -9,24 +9,42 @@ namespace entities void Camera::Move(GLFWwindow* window) { + float movement_speed = 0; + if (glfwGetKey(window, GLFW_KEY_W) == GLFW_PRESS) { - position.z -= SPEED; + movement_speed -= SPEED; } if (glfwGetKey(window, GLFW_KEY_S) == GLFW_PRESS) { - position.z += SPEED; + movement_speed += SPEED; } if (glfwGetKey(window, GLFW_KEY_D) == GLFW_PRESS) { - position.x += SPEED; + rotation.y += ROT_SPEED; } if (glfwGetKey(window, GLFW_KEY_A) == GLFW_PRESS) { - position.x -= SPEED; + rotation.y -= ROT_SPEED; } + + if (glfwGetKey(window, GLFW_KEY_SPACE) == GLFW_PRESS) + { + rotation.x -= ROT_SPEED; + } + + if (glfwGetKey(window, GLFW_KEY_LEFT_SHIFT) == GLFW_PRESS) + { + rotation.x += ROT_SPEED; + } + + float dx = glm::cos(glm::radians(rotation.y + 90)) * movement_speed; + float dz = glm::sin(glm::radians(rotation.y + 90)) * movement_speed; + + position.x += dx; + position.z += dz; } } diff --git a/src/entities/Camera.h b/src/entities/Camera.h index 68dfa5b..6f6fe0a 100644 --- a/src/entities/Camera.h +++ b/src/entities/Camera.h @@ -14,6 +14,7 @@ namespace entities private: // The movement speed of the camera const float SPEED = 0.52f; + const float ROT_SPEED = 1.0f; glm::vec3 position; glm::vec3 rotation; diff --git a/src/main.cpp b/src/main.cpp index 26894ef..bd57547 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -99,12 +99,12 @@ int main(void) // Update const double delta = UpdateDelta(); camera.Move(window); - button.Update(window); // Render render_engine::renderer::Prepare(); + // Start rendering the entities shader.Start(); shader.LoadSkyColor(render_engine::renderer::SKY_COLOR); shader.LoadLights(lights); @@ -119,7 +119,6 @@ int main(void) // Stop rendering the entities shader.Stop(); - // Render GUI items render_engine::renderer::Render(guis, gui_shader);