From 149848dbfa136f828b09253f402de59c00a5a1cf Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Wed, 9 Jun 2021 20:26:57 +0200 Subject: Shoot fireballs into last movement direction --- plugins/movement/movement.c | 21 +++++++++++++++++---- plugins/movement/movement.h | 8 ++++++++ 2 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 plugins/movement/movement.h (limited to 'plugins/movement') 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 -- cgit v1.2.3