diff options
author | scratko <m@scratko.xyz> | 2024-04-17 17:00:48 +0300 |
---|---|---|
committer | scratko <m@scratko.xyz> | 2024-04-17 18:33:03 +0300 |
commit | ef3844bf2128fa82f20c5995d1fca66fadba2ce3 (patch) | |
tree | 905048a285a8cd8fd6a070ce3b6c075e9681e59a /ghosts.c | |
parent | 194f71c150eb9ee696acca17176092e8b0ce6e4f (diff) | |
download | pacman-ef3844bf2128fa82f20c5995d1fca66fadba2ce3.tar.gz pacman-ef3844bf2128fa82f20c5995d1fca66fadba2ce3.tar.bz2 pacman-ef3844bf2128fa82f20c5995d1fca66fadba2ce3.zip |
Added colors
Changed the number of pacman's lives.
Fixed clear_or_revert_symbol().
Target hit display.
Changed ghost initialization.
Clearing ghost positions is moved to the function.
Added flag in struct ghost_type (reached_pacman).
Changed catching stage.
Now eating an energizer resets the counter.
Diffstat (limited to 'ghosts.c')
-rw-r--r-- | ghosts.c | 46 |
1 files changed, 21 insertions, 25 deletions
@@ -17,13 +17,8 @@ void initialize_ghost(struct ghost_type *ghost, enum ghost_color color) ghost->home_position.y = red_home_y; ghost->home_position.x = red_home_x; ghost->color = red; - ghost->frightened_status = 0; - ghost->direction = none; ghost->prison_params.position.x = red_prison_x; ghost->prison_params.position.y = red_prison_y; - ghost->prison_params.prison_counter = 0; - ghost->prison_params.active = 0; - ghost->capture_info.status = 0; break; case pink: ghost->position.y = pink_y; @@ -31,13 +26,8 @@ void initialize_ghost(struct ghost_type *ghost, enum ghost_color color) ghost->home_position.y = pink_home_y; ghost->home_position.x = pink_home_x; ghost->color = pink; - ghost->frightened_status = 0; - ghost->direction = none; ghost->prison_params.position.x = pink_prison_x; ghost->prison_params.position.y = pink_prison_y; - ghost->prison_params.prison_counter = 0; - ghost->prison_params.active = 0; - ghost->capture_info.status = 0; break; case blue: ghost->position.y = blue_y; @@ -45,13 +35,8 @@ void initialize_ghost(struct ghost_type *ghost, enum ghost_color color) ghost->home_position.y = blue_home_y; ghost->home_position.x = blue_home_x; ghost->color = blue; - ghost->frightened_status = 0; - ghost->direction = none; ghost->prison_params.position.x = blue_prison_x; ghost->prison_params.position.y = blue_prison_y; - ghost->prison_params.prison_counter = 0; - ghost->prison_params.active = 0; - ghost->capture_info.status = 0; break; case orange: ghost->position.y = orange_y; @@ -59,15 +44,16 @@ void initialize_ghost(struct ghost_type *ghost, enum ghost_color color) ghost->home_position.y = orange_home_y; ghost->home_position.x = orange_home_x; ghost->color = orange; - ghost->frightened_status = 0; - ghost->direction = none; ghost->prison_params.position.x = orange_prison_x; ghost->prison_params.position.y = orange_prison_y; + break; + } + ghost->frightened_status = 0; + ghost->direction = none; ghost->prison_params.prison_counter = 0; ghost->prison_params.active = 0; ghost->capture_info.status = 0; - break; - } + ghost->reached_pacman = 0; } void pull_out_ghosts(int *get_out_stage, @@ -114,12 +100,11 @@ static void change_position(struct ghost_type *ghost, change_point_if_outside_tunnel(&ghost->position); } -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 queue *eaten_coins) +void clear_ghost_positions(game_space field, const struct queue *eaten_coins, + const struct ghost_type *red_ghost, + const struct ghost_type *pink_ghost, + const struct ghost_type *blue_ghost, + const struct ghost_type *orange_ghost) { clear_or_revert_symbol(field, red_ghost->position, ghost_char, eaten_coins); clear_or_revert_symbol(field, pink_ghost->position, ghost_char, @@ -128,6 +113,17 @@ void make_ghost_moves(game_space field, eaten_coins); clear_or_revert_symbol(field, orange_ghost->position, ghost_char, eaten_coins); +} + +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 queue *eaten_coins) +{ + clear_ghost_positions(field, eaten_coins, red_ghost, pink_ghost, blue_ghost, + orange_ghost); change_position(red_ghost, red_ghost->direction); change_position(pink_ghost, pink_ghost->direction); change_position(blue_ghost, blue_ghost->direction); |