keyboard.c
raw
1#include "all.h"
2
3void handle_keyboard_event(unsigned char key, int x, int y) {
4 (void)x; (void)y;
5 float fraction = 0.05f;
6
7 switch (key) {
8 case 27: exit(0); break;
9 case 'w': game.y_offset += fraction; break;
10 case 's': game.y_offset -= fraction; break;
11 case 'a': game.x_offset -= fraction; break;
12 case 'd': game.x_offset += fraction; break;
13 case '+':
14 game.target_fps += 5;
15 printf("Target FPS: %d\n", game.target_fps);
16 break;
17 case '-':
18 if (game.target_fps > 5) game.target_fps -= 5;
19 printf("Target FPS: %d\n", game.target_fps);
20 break;
21 default:
22 printf("Unknown key: %c\n", key);
23 break;
24 }
25}
26