From e79798e5ecc85738813363c3025961b0099802fb Mon Sep 17 00:00:00 2001 From: scratko Date: Thu, 31 Jul 2025 03:55:59 +0300 Subject: Add README and revise distance metric Added many inline comments for clarity. Introduced initial version of README with gameplay details, controls, and AI logic. Replaced Euclidean distance with Manhattan distance in standard_distance() to better match grid-based movement without diagonal traversal. --- pacman.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'pacman.c') diff --git a/pacman.c b/pacman.c index 15a4b63..eaa453e 100644 --- a/pacman.c +++ b/pacman.c @@ -207,6 +207,7 @@ static void change_mode(struct mode_type *mode_params, struct pacman *pac) mode_params->current_mode = scatter; mode_params->chase_counter = 0; ++mode_params->phase_number; + /* Leave the chase phase until the end of the game */ if(mode_params->phase_number == phase_limit) mode_params->current_mode = chase; if(mode_params->phase_number != phase_limit) @@ -511,6 +512,15 @@ int main() struct mode_type mode_params; struct game_params_type game_options; int key; + /* + * This stores the direction requested by the player (via arrow keys). + * If Pac-Man can't immediately switch to that direction (due to a wall), + * the input is remembered here. On the next iteration, the game checks + * again whether turning in this stored direction is possible, and performs + * the turn if so. This adds a small input buffer window, making controls + * more forgiving: if the player pressed the key slightly early, the turn + * still happens smoothly. + */ enum movement_direction stored_direction; srand(time(NULL)); initscr(); -- cgit v1.2.3