diff options
author | scratko <m@scratko.xyz> | 2025-07-31 03:55:59 +0300 |
---|---|---|
committer | scratko <m@scratko.xyz> | 2025-08-12 03:43:35 +0300 |
commit | e79798e5ecc85738813363c3025961b0099802fb (patch) | |
tree | 6fce5a438871f0a8eeeb1160b7153e5914d5adc9 /pacman.c | |
parent | cba2e3ddd2596f519750aed1179da8a757023850 (diff) | |
download | pacman-e79798e5ecc85738813363c3025961b0099802fb.tar.gz pacman-e79798e5ecc85738813363c3025961b0099802fb.tar.bz2 pacman-e79798e5ecc85738813363c3025961b0099802fb.zip |
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.
Diffstat (limited to 'pacman.c')
-rw-r--r-- | pacman.c | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -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(); |