diff options
author | scratko <m@scratko.xyz> | 2024-04-12 03:17:46 +0300 |
---|---|---|
committer | scratko <m@scratko.xyz> | 2024-04-12 03:17:46 +0300 |
commit | 04a6703fd66a7d34b2556a9c203c4dada3baca38 (patch) | |
tree | 3d2cbdaae515d90747e507ba8a8ebfd7bdc44fed /pac.c | |
parent | 235f8481502263fcdb4823ff0bc4e8f831bc934d (diff) | |
download | pacman-04a6703fd66a7d34b2556a9c203c4dada3baca38.tar.gz pacman-04a6703fd66a7d34b2556a9c203c4dada3baca38.tar.bz2 pacman-04a6703fd66a7d34b2556a9c203c4dada3baca38.zip |
Added behavior modes
Reverse direction
Random direction
Diffstat (limited to 'pac.c')
-rw-r--r-- | pac.c | 19 |
1 files changed, 16 insertions, 3 deletions
@@ -9,6 +9,7 @@ void initialize_pac(struct pacman *pac) pac->position.y = pac_y; pac->position.x = pac_x; pac->direction = none; + pac->is_energizer_eaten = 0; } static enum movement_direction get_matching_for_directions(game_space field, @@ -124,8 +125,8 @@ void change_pac_direction(game_space field, struct pacman *pac, int key, static int is_coin_symbol(int symbol) { return - symbol == coin || symbol == one_path || symbol == two_paths || - symbol == three_paths; + symbol == coin || symbol == energizer || symbol == one_path || + symbol == two_paths || symbol == three_paths; } static int check_coin(game_space field, struct coordinates position, @@ -139,6 +140,15 @@ static int check_coin(game_space field, struct coordinates position, !queue_consists_point(eaten_coins, position); } +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) + pac->is_energizer_eaten = 1; +} + void make_pac_move(game_space field, struct pacman *pac, struct queue *eaten_coins) { @@ -159,7 +169,10 @@ void make_pac_move(game_space field, struct pacman *pac, default: return; } - if(check_coin(field, pac->position, eaten_coins)) + if(check_coin(field, pac->position, eaten_coins)) { queue_push(eaten_coins, &pac->position); + ++pac->coins_eaten; + } change_point_if_outside_tunnel(&pac->position); + eat_energizer(field, pac); } |