Skip to content

Commit

Permalink
Implement 'e' and 'q' keys for camera elevation control (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
luciddream-tsin authored Jan 17, 2024
1 parent 3e73932 commit 41e3eeb
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
21 changes: 21 additions & 0 deletions src/engine/input/Keyboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ namespace Atlas {
location += camera->direction * movement.x * deltaTime * speed;
location += camera->right * movement.y * deltaTime * speed;

location.y += movement.z * deltaTime * speed;

float progress = glm::clamp(reactivity * deltaTime, 0.0f, 1.0f);

camera->location = glm::mix(camera->location, location, progress);
Expand Down Expand Up @@ -107,6 +109,25 @@ namespace Atlas {
movement.y += 1.0f;
}


if (event.keyCode == AE_KEY_E && event.state == AE_BUTTON_PRESSED && !event.repeat) {
movement.z += 1.0f;
}

if (event.keyCode == AE_KEY_E && event.state == AE_BUTTON_RELEASED) {
movement.z -= 1.0f;
}


if (event.keyCode == AE_KEY_Q && event.state == AE_BUTTON_PRESSED && !event.repeat) {
movement.z -= 1.0f;
}

if (event.keyCode == AE_KEY_Q && event.state == AE_BUTTON_RELEASED) {
movement.z += 1.0f;
}


}

void KeyboardHandler::DeepCopy(const KeyboardHandler& that) {
Expand Down
2 changes: 1 addition & 1 deletion src/engine/input/Keyboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ namespace Atlas {
void DeepCopy(const KeyboardHandler& that);

vec3 location = vec3(0.0f);
vec2 movement = vec2(0.0f);
vec3 movement = vec3(0.0f);

int32_t eventHandle = -1;

Expand Down

0 comments on commit 41e3eeb

Please sign in to comment.