diff options
author | scratko <m@scratko.xyz> | 2024-04-11 15:04:37 +0300 |
---|---|---|
committer | scratko <m@scratko.xyz> | 2024-04-11 15:04:37 +0300 |
commit | 235f8481502263fcdb4823ff0bc4e8f831bc934d (patch) | |
tree | aa7bac493c447571ac88f3793447e05ed17c2d6a /field.c | |
parent | 76b875e095d8b9ca3f6058fbfc0ab2669eed852d (diff) | |
download | pacman-235f8481502263fcdb4823ff0bc4e8f831bc934d.tar.gz pacman-235f8481502263fcdb4823ff0bc4e8f831bc934d.tar.bz2 pacman-235f8481502263fcdb4823ff0bc4e8f831bc934d.zip |
Removed the reverse motion for ghosts
Yellow intersections added.
Diffstat (limited to 'field.c')
-rw-r--r-- | field.c | 28 |
1 files changed, 24 insertions, 4 deletions
@@ -17,7 +17,7 @@ static const char field_sample[field_height][field_width] = { {"/1....2//1..1//1..1//2....1/"}, {"//////.///// // /////.//////"}, {" /.///// // /////./ "}, - {" /.//1 1//./ "}, + {" /.//1 y y 1//./ "}, {" /.// ///##/// //./ "}, {"//////.// / /2 2//////"}, {" 3 2/ / //2 "}, @@ -27,7 +27,7 @@ static const char field_sample[field_height][field_width] = { {"/1....3..2..1//1..2..3....1/"}, {"/.////./////.//./////.////./"}, {"/.////./////.//./////.////./"}, - {"/1.1//2..2..2..2..2..2//1.1/"}, + {"/1.1//2..2..y..y..2..2//1.1/"}, {"///.//.//.////////.//.//.///"}, {"///.//.//.////////.//.//.///"}, {"/1.2..1//1..1//1..1//1..2.1/"}, @@ -128,6 +128,7 @@ void clear_or_revert_symbol(game_space field, struct coordinates position, case one_path: case two_paths: case three_paths: + case yellow_block: if(field_has_coin(y, x)) queue_consists_point(eaten_coins, position) ? addch(' ') : addch('.'); @@ -165,17 +166,26 @@ enum intersection_type get_intersection(const game_space field, return two_paths; case three_paths: return three_paths; + case yellow_block: + return yellow_block; default: return direct_path; } } +/* + * last conditions x-1 == left_outside_tunnel_x and + * x+1 == right_outside_tunnel_x are used by only pacman (while + * cheking remaining direction) + */ struct free_directions find_free_directions(const game_space field, int y, int x) { struct free_directions found_paths; - found_paths.left = field[y][x-1] != '/' && field[y][x-1] != '#' ? 1 : 0; - found_paths.right = field[y][x+1] != '/' && field[y][x+1] != '#' ? 1 : 0; + found_paths.left = (field[y][x-1] != '/' && field[y][x-1] != '#') || + x-1 == left_outside_tunnel_x ? 1 : 0; + found_paths.right = (field[y][x+1] != '/' && field[y][x+1] != '#') || + x+1 == right_outside_tunnel_x ? 1 : 0; found_paths.up = field[y-1][x] != '/' && field[y-1][x] != '#' ? 1 : 0; found_paths.down = field[y+1][x] != '/' && field[y+1][x] != '#' ? 1 : 0; return found_paths; @@ -186,3 +196,13 @@ int is_obstacle(const game_space field, int x, int y) int symbol = field[y][x]; return symbol == door || symbol == block; } + +void change_point_if_outside_tunnel(struct coordinates *point) +{ + if(point->x == left_outside_tunnel_x) { + point->x = right_outside_tunnel_x - 1; + return; + } + if(point->x == right_outside_tunnel_x) + point->x = left_outside_tunnel_x + 1; +} |