aboutsummaryrefslogtreecommitdiff
path: root/plugins/movement
diff options
context:
space:
mode:
authorElias Fleckenstein <eliasfleckenstein@web.de>2021-06-09 20:26:57 +0200
committerElias Fleckenstein <eliasfleckenstein@web.de>2021-06-09 20:26:57 +0200
commit149848dbfa136f828b09253f402de59c00a5a1cf (patch)
tree1b18fe1c8611e40fb19d7828dcb45ccc22808464 /plugins/movement
parent98e09a9f519c2943fab1bee4884e66b83951c867 (diff)
downloaddungeon_game-149848dbfa136f828b09253f402de59c00a5a1cf.tar.xz
Shoot fireballs into last movement direction
Diffstat (limited to 'plugins/movement')
-rw-r--r--plugins/movement/movement.c21
-rw-r--r--plugins/movement/movement.h8
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