diff options
author | scratko <m@scratko.xyz> | 2025-07-31 03:55:59 +0300 |
---|---|---|
committer | scratko <m@scratko.xyz> | 2025-07-31 04:07:30 +0300 |
commit | 8fe2319e189b4d830a892b8c686d08cff5556962 (patch) | |
tree | 60479d39949e0a13efce32d75e5fec1886eae09f /pacman.c | |
parent | cba2e3ddd2596f519750aed1179da8a757023850 (diff) | |
download | pacman-8fe2319e189b4d830a892b8c686d08cff5556962.tar.gz pacman-8fe2319e189b4d830a892b8c686d08cff5556962.tar.bz2 pacman-8fe2319e189b4d830a892b8c686d08cff5556962.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(); |