diff options
Diffstat (limited to 'plugins/movement')
-rw-r--r-- | plugins/movement/movement.c | 21 | ||||
-rw-r--r-- | plugins/movement/movement.h | 8 |
2 files changed, 25 insertions, 4 deletions
diff --git a/plugins/movement/movement.c b/plugins/movement/movement.c index 494c8b0..25c5f93 100644 --- a/plugins/movement/movement.c +++ b/plugins/movement/movement.c @@ -1,23 +1,36 @@ #include "../game/game.h" +enum direction last_player_move; + +void move_player(enum direction dir) +{ + int x, y; + x = y = 0; + + dir_to_xy(dir, &x, &y); + last_player_move = dir; + + move(&player, x, y); +} + static void move_up() { - move(&player, 0, -1); + move_player(UP); } static void move_left() { - move(&player, -1, 0); + move_player(LEFT); } static void move_down() { - move(&player, 0, 1); + move_player(DOWN); } static void move_right() { - move(&player, 1, 0); + move_player(RIGHT); } __attribute__((constructor)) static void init() diff --git a/plugins/movement/movement.h b/plugins/movement/movement.h new file mode 100644 index 0000000..c3afdac --- /dev/null +++ b/plugins/movement/movement.h @@ -0,0 +1,8 @@ +#ifndef _MOVEMENT_H_ +#define _MOVEMENT_H_ +#include "../game/game.h" + +extern enum direction last_player_move; +void move_player(enum direction dir); + +#endif |