back to scratko.xyz
aboutsummaryrefslogtreecommitdiff
path: root/pacman.c
diff options
context:
space:
mode:
Diffstat (limited to 'pacman.c')
-rw-r--r--pacman.c10
1 files changed, 10 insertions, 0 deletions
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();