]> git.lizzy.rs Git - dungeon_game.git/blob - plugins/movement/movement.c
494c8b0a47d965f7b144d477ad8f83dfad15733a
[dungeon_game.git] / plugins / movement / movement.c
1 #include "../game/game.h"
2
3 static void move_up()
4 {
5         move(&player, 0, -1);
6 }
7
8 static void move_left()
9 {
10         move(&player, -1, 0);
11 }
12
13 static void move_down()
14 {
15         move(&player, 0, 1);
16 }
17
18 static void move_right()
19 {
20         move(&player, 1, 0);
21 }
22
23 __attribute__((constructor)) static void init()
24 {
25         register_input_handler('w', (struct input_handler) {
26                 .run_if_dead = false,
27                 .callback = &move_up,
28         });
29
30         register_input_handler('a', (struct input_handler) {
31                 .run_if_dead = false,
32                 .callback = &move_left,
33         });
34
35         register_input_handler('s', (struct input_handler) {
36                 .run_if_dead = false,
37                 .callback = &move_down,
38         });
39
40         register_input_handler('d', (struct input_handler) {
41                 .run_if_dead = false,
42                 .callback = &move_right,
43         });
44 }