]> git.lizzy.rs Git - shadowclad.git/blob - src/game/input.c
f52a27e79742ec4bff65c73279399096e4dc4b5f
[shadowclad.git] / src / game / input.c
1 #include "input.h"
2
3 #include <GLFW/glfw3.h>
4
5 #include "player.h"
6
7 void keyboardInput(int key, int scancode, int action, int mods) {
8         switch (key) {
9                 case GLFW_KEY_W:
10                         if (action == GLFW_PRESS) {
11                                 startMovement(DIRECTION_UP);
12                         }
13                         else if (action == GLFW_RELEASE) {
14                                 stopMovement(DIRECTION_UP);
15                         }
16                         break;
17                 case GLFW_KEY_S:
18                         if (action == GLFW_PRESS) {
19                                 startMovement(DIRECTION_DOWN);
20                         }
21                         else if (action == GLFW_RELEASE) {
22                                 stopMovement(DIRECTION_DOWN);
23                         }
24                         break;
25                 case GLFW_KEY_A:
26                         if (action == GLFW_PRESS) {
27                                 startMovement(DIRECTION_LEFT);
28                         }
29                         else if (action == GLFW_RELEASE) {
30                                 stopMovement(DIRECTION_LEFT);
31                         }
32                         break;
33                 case GLFW_KEY_D:
34                         if (action == GLFW_PRESS) {
35                                 startMovement(DIRECTION_RIGHT);
36                         }
37                         else if (action == GLFW_RELEASE) {
38                                 stopMovement(DIRECTION_RIGHT);
39                         }
40                         break;
41                 default:
42                         break;
43         }
44 }