summaryrefslogtreecommitdiffstats
path: root/src/char
diff options
context:
space:
mode:
Diffstat (limited to 'src/char')
-rw-r--r--src/char/enemy.c36
1 files changed, 28 insertions, 8 deletions
diff --git a/src/char/enemy.c b/src/char/enemy.c
index fb259a2..b981da7 100644
--- a/src/char/enemy.c
+++ b/src/char/enemy.c
@@ -25,13 +25,20 @@
#include "char.h"
struct mf_enemy {
- struct mf_char parent;
+ struct mf_char parent;
+ struct mf_char *next_enemy;
};
static int
-_mf_enemy_update(struct mf_char *c __attribute__((__unused__)))
+_mf_enemy_update(struct mf_char *c)
{
- return 0;
+ struct mf_enemy *p = (struct mf_enemy *) c;
+
+ if (p->next_enemy != NULL) {
+ return mf_char_update(p->next_enemy);
+ } else {
+ return 0;
+ }
}
static int
@@ -112,19 +119,28 @@ _mf_enemy_collide(struct mf_char *c)
}
static int
-_mf_enemy_render(struct mf_char *c __attribute__((__unused__)),
- SDL_Renderer *renderer __attribute__((__unused__)))
+_mf_enemy_render(struct mf_char *c, SDL_Renderer *renderer)
{
- return 0;
+ struct mf_enemy *p = (struct mf_enemy *) c;
+
+ if (p->next_enemy != NULL) {
+ return mf_char_render(p->next_enemy, renderer);
+ } else {
+ return 0;
+ }
}
static void
-_mf_enemy_destroy(struct mf_char *c __attribute__((__unused__)))
+_mf_enemy_destroy(struct mf_char *c)
{
+ struct mf_enemy *p = (struct mf_enemy *) c;
+
+ mf_char_destroy(&p->next_enemy);
}
struct mf_char *
-mf_enemy_new(struct mf_maze *maze, int cell_width, int maze_size)
+mf_enemy_new(struct mf_maze *maze, int cell_width, int maze_size,
+ struct mf_char *prev_enemy)
{
struct mf_char *c;
struct mf_enemy *p __attribute__((__unused__));
@@ -163,6 +179,10 @@ mf_enemy_new(struct mf_maze *maze, int cell_width, int maze_size)
_mf_enemy_step(c);
c->cur_dir = c->new_dir;
+ if (prev_enemy != NULL) {
+ ((struct mf_enemy *) prev_enemy)->next_enemy = c;
+ }
+
return c;
}