From 3e619979dafa64c6b2576420ff1ce59462256d5e Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Tue, 10 Aug 2021 02:08:41 -0400 Subject: char: Add collision detection/handling --- (limited to 'src/char/enemy.c') diff --git a/src/char/enemy.c b/src/char/enemy.c index 82cc16b..fb259a2 100644 --- a/src/char/enemy.c +++ b/src/char/enemy.c @@ -97,6 +97,20 @@ _mf_enemy_turn(struct mf_char *c) return 0; } +static void +_mf_enemy_collide(struct mf_char *c) +{ + /* Don't go forward unless necessary */ + switch (c->cur_dir) { + case MF_CHAR_DIR_U_: c->cur_dir = MF_CHAR_DIR_D_; break; + case MF_CHAR_DIR_D_: c->cur_dir = MF_CHAR_DIR_U_; break; + case MF_CHAR_DIR_L_: c->cur_dir = MF_CHAR_DIR_R_; break; + case MF_CHAR_DIR_R_: c->cur_dir = MF_CHAR_DIR_L_; break; + default: c->cur_dir = MF_CHAR_DIR_N_; break; + } + _mf_enemy_step(c); +} + static int _mf_enemy_render(struct mf_char *c __attribute__((__unused__)), SDL_Renderer *renderer __attribute__((__unused__))) -- cgit v0.9.1