back to scratko.xyz
aboutsummaryrefslogtreecommitdiff
path: root/pacman.c
diff options
context:
space:
mode:
authorscratko <m@scratko.xyz>2024-04-11 15:04:37 +0300
committerscratko <m@scratko.xyz>2024-04-11 15:04:37 +0300
commit235f8481502263fcdb4823ff0bc4e8f831bc934d (patch)
treeaa7bac493c447571ac88f3793447e05ed17c2d6a /pacman.c
parent76b875e095d8b9ca3f6058fbfc0ab2669eed852d (diff)
downloadpacman-235f8481502263fcdb4823ff0bc4e8f831bc934d.tar.gz
pacman-235f8481502263fcdb4823ff0bc4e8f831bc934d.tar.bz2
pacman-235f8481502263fcdb4823ff0bc4e8f831bc934d.zip
Removed the reverse motion for ghosts
Yellow intersections added.
Diffstat (limited to 'pacman.c')
-rw-r--r--pacman.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/pacman.c b/pacman.c
index f2e0161..95d121d 100644
--- a/pacman.c
+++ b/pacman.c
@@ -13,6 +13,13 @@ enum {
count_get_out_moves = 5
};
+static int is_up_move_blocked(const struct ghost_type *ghost,
+ enum intersection_type intersection)
+{
+ return intersection == yellow_block && (ghost->direction == left ||
+ ghost->direction == right);
+}
+
static void pathfinder_stage(game_space field, struct pacman pac,
struct ghost_type *red_ghost,
struct ghost_type *pink_ghost,
@@ -48,6 +55,8 @@ static void pathfinder_stage(game_space field, struct pacman pac,
break;
}
intersection = get_intersection(field, current_ghost);
+ if(is_up_move_blocked(current_ghost, intersection))
+ continue;
if(intersection != direct_path)
redirect(field, intersection, current_ghost, target_point,
search_method);