From 155a3c5f91c7a3bd89febfeb9927478961f5ee28 Mon Sep 17 00:00:00 2001 From: scratko Date: Sun, 7 Apr 2024 22:40:47 +0300 Subject: 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. --- ghosts.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'ghosts.c') 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); -- cgit v1.2.3