aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJuan J. Martinez <jjm@usebox.net>2023-07-07 07:21:18 +0100
committerJuan J. Martinez <jjm@usebox.net>2023-07-07 07:21:18 +0100
commit55a4aed50112c06991d1dbb6199248bb4083c6a9 (patch)
treea5f4e06ddcd0944de825003da5d817c7de3b6a25 /src
parentbbe888fc60ba967685be3350509e064277df31f0 (diff)
downloadgold-mine-run-55a4aed50112c06991d1dbb6199248bb4083c6a9.tar.gz
gold-mine-run-55a4aed50112c06991d1dbb6199248bb4083c6a9.zip
Prevent Mr Bones to get stuck turning when can't reach the player
Diffstat (limited to 'src')
-rw-r--r--src/bones.c2
-rw-r--r--src/old.c8
-rw-r--r--src/old.h2
3 files changed, 6 insertions, 6 deletions
diff --git a/src/bones.c b/src/bones.c
index f5d7f42..8891534 100644
--- a/src/bones.c
+++ b/src/bones.c
@@ -33,7 +33,7 @@ void bones_init(Entity *e)
void bones_update(Entity *e)
{
- if (abs(player_y() - e->y) < 8)
+ if (abs(player_y() - e->y) < 8 && e->flags < ENEMY_JUMP_DELAY)
{
if (player_x() > e->x && e->dir != DIR_RIGHT)
e->dir = DIR_RIGHT;
diff --git a/src/old.c b/src/old.c
index 3451118..dcb2994 100644
--- a/src/old.c
+++ b/src/old.c
@@ -13,8 +13,6 @@
#define FRAME_JUMPING 1
#define WALK_CYCLE_FRAMES 4
-#define JUMP_DELAY 2
-
static const Rect frames[2 * 4] =
{
/* right */
@@ -77,7 +75,7 @@ void old_update(Entity *e)
{
e->gravity = GRAVITY_OFF;
e->frame = FRAME_STANDING;
- e->flags = rand() % (JUMP_DELAY * 2);
+ e->flags = rand() % (ENEMY_JUMP_DELAY * 2);
break;
}
e->y++;
@@ -110,7 +108,7 @@ void old_update(Entity *e)
else
e->x++;
- if (e->flags > JUMP_DELAY
+ if (e->flags > ENEMY_JUMP_DELAY
&& map_is_blocked(e->x + 7, e->y - 1)
&& !map_is_blocked(e->x + 7, e->y - 9))
{
@@ -130,7 +128,7 @@ void old_update(Entity *e)
else
e->x--;
- if (e->flags > JUMP_DELAY
+ if (e->flags > ENEMY_JUMP_DELAY
&& map_is_blocked(e->x + 7, e->y - 1)
&& !map_is_blocked(e->x + 7, e->y - 9))
{
diff --git a/src/old.h b/src/old.h
index de70158..58b9528 100644
--- a/src/old.h
+++ b/src/old.h
@@ -1,6 +1,8 @@
#ifndef _OLD_H
#define _OLD_H
+#define ENEMY_JUMP_DELAY 2
+
void old_init(Entity *e);
void old_update(Entity *e);