diff options
author | P. J. McDermott <pj@pehjota.net> | 2021-08-19 17:28:13 (EDT) |
---|---|---|
committer | P. J. McDermott <pj@pehjota.net> | 2021-08-19 17:28:13 (EDT) |
commit | 09775804429ccd7486419b4c539581d6f70e193d (patch) | |
tree | 50ed80a2533cae707c9f4752dd957f69e1150065 /src/char | |
parent | e236632ceea7a7cbee7c4139b0bf86710770077b (diff) | |
download | mazefight-09775804429ccd7486419b4c539581d6f70e193d.zip mazefight-09775804429ccd7486419b4c539581d6f70e193d.tar.gz mazefight-09775804429ccd7486419b4c539581d6f70e193d.tar.bz2 |
char/enemy: Try to fix movement lag
Diffstat (limited to 'src/char')
-rw-r--r-- | src/char/enemy.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/char/enemy.c b/src/char/enemy.c index eeda38d..3f9f994 100644 --- a/src/char/enemy.c +++ b/src/char/enemy.c @@ -133,12 +133,12 @@ _mf_enemy_turn(struct mf_char *c) if (e->allies[i]->cur_x == c->cur_x + dx && e->allies[i]->cur_y == c->cur_y + dy) { /* Another enemy currently in this direction */ - return 0; + return _mf_enemy_step(c); } if (e->allies[i]->new_x == c->cur_x + dx && e->allies[i]->new_y == c->cur_y + dy) { /* Another enemy moving in this direction */ - return 0; + return _mf_enemy_step(c); } } @@ -240,3 +240,13 @@ mf_enemy_random_jump(struct mf_char *c, int maze_size) c->cur_x = rand() / (RAND_MAX / maze_size); c->cur_y = rand() / (RAND_MAX / maze_size); } + +int +mf_enemy_postupdate(struct mf_char *c) +{ + if (c->travel == 0 && c->turning == 0) { + return _mf_enemy_turn(c); + } else { + return 0; + } +} |