back to scratko.xyz
aboutsummaryrefslogtreecommitdiff
path: root/ghosts.h
diff options
context:
space:
mode:
authorscratko <m@scratko.xyz>2024-04-14 21:18:36 +0300
committerscratko <m@scratko.xyz>2024-04-14 21:18:36 +0300
commit0cf5dfed3e492608d044a5fc90c1815fab506fd7 (patch)
treed1efa942e89ab4f064324fcee4c623173abc5298 /ghosts.h
parent91583d5699503e981105beecc51d37b59dc1842e (diff)
downloadpacman-0cf5dfed3e492608d044a5fc90c1815fab506fd7.tar.gz
pacman-0cf5dfed3e492608d044a5fc90c1815fab506fd7.tar.bz2
pacman-0cf5dfed3e492608d044a5fc90c1815fab506fd7.zip
Capture and liberation of ghosts
Fixed coordinate in field_has_coin. Added marks on the field for the liberation zone (1 in front of #). Prison parameters for the ghost are set. Fixed condition in BFS search (additionally exclude the current point in the loop, dx == 0 && dy == 0).
Diffstat (limited to 'ghosts.h')
-rw-r--r--ghosts.h72
1 files changed, 53 insertions, 19 deletions
diff --git a/ghosts.h b/ghosts.h
index d55da6a..3eb58f7 100644
--- a/ghosts.h
+++ b/ghosts.h
@@ -4,25 +4,34 @@
#include "field.h"
enum {
- red_y = 14,
- red_x = 15,
- red_home_y = -1,
- red_home_x = 25,
- pink_y = red_y + 1,
- pink_x = red_x - 2,
- pink_home_y = red_home_y,
- pink_home_x = 2,
- blue_y = red_y,
- blue_x = red_x-1,
- blue_home_y = 29,
- blue_home_x = 27,
- orange_y = red_y + 1,
- orange_x = red_x - 3,
- orange_home_y = blue_home_y,
- orange_home_x = 0,
- pink_shift = 4,
- blue_shift = 2,
- orange_search_limit = 8
+ red_y = 14,
+ red_x = 15,
+ red_home_y = -1,
+ red_home_x = 25,
+ pink_y = red_y + 1,
+ pink_x = red_x - 2,
+ pink_home_y = red_home_y,
+ pink_home_x = 2,
+ blue_y = red_y,
+ blue_x = red_x-1,
+ blue_home_y = 29,
+ blue_home_x = 27,
+ orange_y = red_y + 1,
+ orange_x = red_x - 3,
+ orange_home_y = blue_home_y,
+ orange_home_x = 0,
+ pink_shift = 4,
+ blue_shift = 2,
+ orange_search_limit = 8,
+ red_prison_y = 14,
+ red_prison_x = 14,
+ pink_prison_y = red_prison_y + 1,
+ pink_prison_x = red_prison_x,
+ blue_prison_y = red_prison_y,
+ blue_prison_x = red_prison_x - 1,
+ orange_prison_y = red_prison_y + 1,
+ orange_prison_x = red_prison_x - 1,
+ liberation_y = 12
};
enum ghost_color { red, pink, blue, orange };
@@ -34,12 +43,26 @@ struct coordinates {
int x;
};
+struct prison {
+ int prison_counter;
+ struct coordinates position;
+ int active;
+};
+
+struct capture {
+ struct coordinates previous_pac_position;
+ struct coordinates previous_ghost_position;
+ int status;
+};
+
struct ghost_type {
struct coordinates position;
struct coordinates home_position;
enum ghost_color color;
int frightened_status;
enum movement_direction direction;
+ struct prison prison_params;
+ struct capture capture_info;
};
void initialize_ghost(struct ghost_type *ghost, enum ghost_color color);
@@ -81,4 +104,15 @@ void reverse_all_ghosts(struct ghost_type *red_ghost,
struct ghost_type *blue_ghost,
struct ghost_type *orange_ghost);
+void set_frightened_status(int status, struct ghost_type *red_ghost,
+ struct ghost_type *pink_ghost,
+ struct ghost_type *blue_ghost,
+ struct ghost_type *orange_ghost);
+
+int is_pac_nearby(struct pacman pac, struct ghost_type ghost);
+
+void set_capture_info(struct ghost_type *ghost, const struct pacman *pac);
+
+void catch_ghost(const game_space field, struct ghost_type *ghost);
+
#endif