back to scratko.xyz
aboutsummaryrefslogtreecommitdiff
path: root/ghosts.c
diff options
context:
space:
mode:
authorscratko <m@scratko.xyz>2024-04-07 22:40:47 +0300
committerscratko <m@scratko.xyz>2024-04-07 22:40:47 +0300
commit155a3c5f91c7a3bd89febfeb9927478961f5ee28 (patch)
tree1953cd610d4a06c51aaedb728edd6131a4fa426a /ghosts.c
parent2c2448cc94b8f17ac699814a75110411d57f3bea (diff)
downloadpacman-155a3c5f91c7a3bd89febfeb9927478961f5ee28.tar.gz
pacman-155a3c5f91c7a3bd89febfeb9927478961f5ee28.tar.bz2
pacman-155a3c5f91c7a3bd89febfeb9927478961f5ee28.zip
Tracking coins eaten
The initialization of ncurses parameters and ghosts was put into functions. The order of movements has been changed: now pacman moves first. Accounting for eaten coins. Correct coin erasure.
Diffstat (limited to 'ghosts.c')
-rw-r--r--ghosts.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/ghosts.c b/ghosts.c
index 7a320ec..0029702 100644
--- a/ghosts.c
+++ b/ghosts.c
@@ -92,16 +92,16 @@ void make_ghost_moves(game_space field,
struct ghost_type *red_ghost,
struct ghost_type *pink_ghost,
struct ghost_type *blue_ghost,
- struct ghost_type *orange_ghost)
+ struct ghost_type *orange_ghost,
+ struct queue *eaten_coins)
{
- eat_or_revert_symbol(field, red_ghost->position.y, red_ghost->position.x,
- ghost_char);
- eat_or_revert_symbol(field, pink_ghost->position.y, pink_ghost->position.x,
- ghost_char);
- eat_or_revert_symbol(field, blue_ghost->position.y, blue_ghost->position.x,
- ghost_char);
- eat_or_revert_symbol(field, orange_ghost->position.y,
- orange_ghost->position.x, ghost_char);
+ clear_or_revert_symbol(field, red_ghost->position, ghost_char, eaten_coins);
+ clear_or_revert_symbol(field, pink_ghost->position, ghost_char,
+ eaten_coins);
+ clear_or_revert_symbol(field, blue_ghost->position, ghost_char,
+ eaten_coins);
+ clear_or_revert_symbol(field, orange_ghost->position, ghost_char,
+ eaten_coins);
change_position(red_ghost, red_ghost->direction);
change_position(pink_ghost, pink_ghost->direction);
change_position(blue_ghost, blue_ghost->direction);
@@ -189,7 +189,7 @@ void breadth_first_search(game_space field, struct ghost_type *ghost,
near_point = get_near_point(consider_point, dx, dy);
if(is_obstacle(field, near_point.x, near_point.y))
continue;
- if(is_consist_point(&next_points, near_point))
+ if(queue_consists_point(&next_points, near_point))
continue;
#if 0
init_pair(1, COLOR_RED, COLOR_BLACK);