summaryrefslogtreecommitdiffstats
path: root/src/char
diff options
context:
space:
mode:
Diffstat (limited to 'src/char')
-rw-r--r--src/char/enemy.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/src/char/enemy.c b/src/char/enemy.c
index 0644ed3..6b1440f 100644
--- a/src/char/enemy.c
+++ b/src/char/enemy.c
@@ -28,15 +28,10 @@ struct mf_enemy {
struct mf_char parent;
int num_allies;
struct mf_char **allies;
+ int waiting;
};
static int
-_mf_enemy_update(struct mf_char *c __attribute__((__unused__)))
-{
- return 0;
-}
-
-static int
_mf_enemy_step(struct mf_char *c)
{
struct mf_enemy *e = (struct mf_enemy *) c;
@@ -103,11 +98,14 @@ _mf_enemy_step(struct mf_char *c)
}
/* Move */
c->new_dir = dirs[i];
+ e->waiting = SDL_FALSE;
return 0;
next_dir:
continue;
}
+ c->new_dir = MF_CHAR_DIR_N_;
+ e->waiting = SDL_TRUE;
return 0;
}
@@ -120,6 +118,18 @@ _mf_enemy_turn(struct mf_char *c)
return 0;
}
+static int
+_mf_enemy_update(struct mf_char *c)
+{
+ struct mf_enemy *e = (struct mf_enemy *) c;
+
+ if (e->waiting == SDL_TRUE) {
+ return _mf_enemy_step(c);
+ } else {
+ return 0;
+ }
+}
+
static void
_mf_enemy_collide(struct mf_char *c)
{
@@ -189,6 +199,7 @@ mf_enemy_new(struct mf_maze *maze, int cell_width, int maze_size,
e->num_allies = num_allies;
e->allies = allies;
+ e->waiting = SDL_FALSE;
return c;
}