Skip to content

Commit 32d9f1a

Browse files
committed
Add WASD-controls as an alternative to arrow keys
1 parent c512e8d commit 32d9f1a

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

common/controls.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,19 +82,23 @@ void computeMatricesFromInputs(){
8282
glm::vec3 left = (-1.0f)*right;
8383

8484
// Move forward
85-
if (glfwGetKey( window, GLFW_KEY_UP ) == GLFW_PRESS){
85+
if (glfwGetKey( window, GLFW_KEY_UP ) == GLFW_PRESS
86+
|| glfwGetKey( window, GLFW_KEY_W ) == GLFW_PRESS){
8687
position += forwards * deltaTime * speed;
8788
}
8889
// Move backward
89-
if (glfwGetKey( window, GLFW_KEY_DOWN ) == GLFW_PRESS){
90+
if (glfwGetKey( window, GLFW_KEY_DOWN ) == GLFW_PRESS
91+
|| glfwGetKey( window, GLFW_KEY_S ) == GLFW_PRESS){
9092
position += backwards * deltaTime * speed;
9193
}
9294
// Strafe right
93-
if (glfwGetKey( window, GLFW_KEY_RIGHT ) == GLFW_PRESS){
95+
if (glfwGetKey( window, GLFW_KEY_RIGHT ) == GLFW_PRESS
96+
|| glfwGetKey( window, GLFW_KEY_D ) == GLFW_PRESS){
9497
position += right * deltaTime * speed;
9598
}
9699
// Strafe left
97-
if (glfwGetKey( window, GLFW_KEY_LEFT ) == GLFW_PRESS){
100+
if (glfwGetKey( window, GLFW_KEY_LEFT ) == GLFW_PRESS
101+
|| glfwGetKey( window, GLFW_KEY_A ) == GLFW_PRESS){
98102
position += left * deltaTime * speed;
99103
}
100104
// Move up

0 commit comments

Comments
 (0)