From 91583d5699503e981105beecc51d37b59dc1842e Mon Sep 17 00:00:00 2001 From: scratko Date: Fri, 12 Apr 2024 16:33:07 +0300 Subject: Coin checks Coin checks in yellow blocks and stars. Fixed arguments of find_free_directions function. --- pac.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'pac.c') diff --git a/pac.c b/pac.c index dcd3b40..a3cae71 100644 --- a/pac.c +++ b/pac.c @@ -18,7 +18,7 @@ static enum movement_direction get_matching_for_directions(game_space field, direction) { struct free_directions free_paths = - find_free_directions(field, pac->position.y, pac->position.x); + find_free_directions(field, pac->position.x, pac->position.y); switch(direction) { case left: return free_paths.left ? left : none; @@ -40,7 +40,7 @@ void check_remaining_direction(game_space field, struct pacman *pac, { enum movement_direction temp_direction; struct free_directions free_path = - find_free_directions(field, pac->position.y, pac->position.x); + find_free_directions(field, pac->position.x, pac->position.y); enum movement_direction current_direction = stored_direction ? *stored_direction : pac->direction; temp_direction = get_correct_path(pac, free_path, current_direction); @@ -86,8 +86,8 @@ void change_pac_direction(game_space field, struct pacman *pac, int key, { enum state { no, yes } is_changed_direction; is_changed_direction = no; - struct free_directions path = find_free_directions(field, pac->position.y, - pac->position.x); + struct free_directions path = find_free_directions(field, pac->position.x, + pac->position.y); switch(key) { case KEY_LEFT: if(path.left) { @@ -145,8 +145,10 @@ static void eat_energizer(game_space field, struct pacman *pac) int x, y; x = pac->position.x; y = pac->position.y; - if(field[y][x] == energizer) + if(field[y][x] == energizer) { pac->is_energizer_eaten = 1; + clear_energizer(field, pac->position); + } } void make_pac_move(game_space field, struct pacman *pac, -- cgit v1.2.3