diff --git a/Camera.cpp b/Camera.cpp index bf49309..11bfa31 100644 --- a/Camera.cpp +++ b/Camera.cpp @@ -1,4 +1,5 @@ #include "Camera.h" +#include "Input.h" using namespace DirectX; @@ -21,7 +22,7 @@ Camera::~Camera() void Camera::Update(float _dt) { - transform.TranslateRelative(0, 0, _dt); + ReadInput(_dt); UpdateViewMatrix(); } @@ -79,3 +80,25 @@ void Camera::SetFarClip(float _far) clipFar = _far; UpdateProjectionMatrix(); } + +void Camera::ReadInput(float _dt) +{ + Input& input = Input::GetInstance(); + + float modify = 1.0f; + float moveLong = 0; + float moveLat = 0; + float moveVert = 0; + + if (input.KeyDown('W')) moveLong += 1.0f; + if (input.KeyDown('S')) moveLong -= 1.0f; + if (input.KeyDown('D')) moveLat += 1.0f; + if (input.KeyDown('A')) moveLat -= 1.0f; + if (input.KeyDown('E')) moveVert += 1.0f; + if (input.KeyDown('Q')) moveVert -= 1.0f; + if (input.KeyDown(VK_SHIFT)) modify *= 2.0f; + if (input.KeyDown(VK_CONTROL)) modify /= 2.0f; + + transform.TranslateRelative(moveLat * _dt * modify, 0, moveLong * _dt * modify); + transform.TranslateAbsolute(0, moveVert * _dt * modify, 0); +} diff --git a/Camera.h b/Camera.h index 5e49872..384ad64 100644 --- a/Camera.h +++ b/Camera.h @@ -32,4 +32,6 @@ private: DirectX::XMFLOAT4X4 projectionMatrix; Transform transform; + + void ReadInput(float _dt); };