back to scratko.xyz
aboutsummaryrefslogtreecommitdiff
path: root/field.c
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 /field.c
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 'field.c')
-rw-r--r--field.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/field.c b/field.c
index 2dcd783..340e380 100644
--- a/field.c
+++ b/field.c
@@ -17,7 +17,7 @@ static const char field_sample[field_height][field_width] = {
{"/1....2//1..1//1..1//2....1/"},
{"//////.///// // /////.//////"},
{" /.///// // /////./ "},
- {" /.//1 y y 1//./ "},
+ {" /.//1 y11y 1//./ "},
{" /.// ///##/// //./ "},
{"//////.// / /2 2//////"},
{" 3 2/ / //2 "},
@@ -55,9 +55,10 @@ game_space get_new_field()
int field_has_coin(int x, int y)
{
- return !((x == 12 && y == 9) || (x == 12 && y == 18) ||
- (x == 14 && y == 18) || (x == 15 && y == 9) ||
- (x == 17 && y == 9) || (x == 17 && y == 18));
+ return !((x == 9 && y == 12)|| (x == 18 && y == 12) ||
+ (x == 18 && y == 14) || (x == 9 && y == 15) ||
+ (x == 9 && y == 17) || (x == 18 && y == 17) ||
+ (x == 13 && y == 12) || (x == 14 && y == 12));
}
int field_has_energizer(const game_space field, int x, int y)
@@ -242,3 +243,14 @@ void clear_energizer(game_space field, struct coordinates point)
y = point.y;
field[y][x] = ' ';
}
+
+int is_equal_points(struct coordinates first_point, struct coordinates
+ second_point)
+{
+ int x1, y1, x2, y2;
+ x1 = first_point.x;
+ y1 = first_point.y;
+ x2 = second_point.x;
+ y2 = second_point.y;
+ return x1 == x2 && y1 == y2;
+}