back to scratko.xyz
aboutsummaryrefslogtreecommitdiff
path: root/pac.c
diff options
context:
space:
mode:
authorscratko <m@scratko.xyz>2024-04-12 16:33:07 +0300
committerscratko <m@scratko.xyz>2024-04-12 16:33:07 +0300
commit91583d5699503e981105beecc51d37b59dc1842e (patch)
treecce70cc6ff3b045d3f0997727add1fb83af2a382 /pac.c
parent04a6703fd66a7d34b2556a9c203c4dada3baca38 (diff)
downloadpacman-91583d5699503e981105beecc51d37b59dc1842e.tar.gz
pacman-91583d5699503e981105beecc51d37b59dc1842e.tar.bz2
pacman-91583d5699503e981105beecc51d37b59dc1842e.zip
Coin checks
Coin checks in yellow blocks and stars. Fixed arguments of find_free_directions function.
Diffstat (limited to 'pac.c')
-rw-r--r--pac.c12
1 files changed, 7 insertions, 5 deletions
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,