Add ghost CPUs with original Pac-Man AI targeting
Implement four ghosts (Blinky, Pinky, Inky, Clyde) with authentic Pac-Man AI: Blinky chases directly, Pinky targets 2 tiles ahead (with original up-direction bug), Inky uses vector doubling from Blinky, Clyde switches to scatter within 8-tile radius. Includes chase/scatter mode cycling, ghost house exit with staggered delays, directional sprite rendering with animation, and ghost-pacman collision detection. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -33,9 +33,54 @@
|
||||
sprite-scale-pacman
|
||||
sprite-scale-key
|
||||
sprite-scale-key-ui
|
||||
sprite-scale-ghost
|
||||
|
||||
;; Movement
|
||||
pacman-speed-ms
|
||||
ghost-speed-ms
|
||||
|
||||
;; Ghost house
|
||||
ghost-house-door-row
|
||||
ghost-house-door-col-left
|
||||
ghost-house-door-col-right
|
||||
ghost-house-exit-row
|
||||
ghost-house-exit-col
|
||||
|
||||
;; Ghost start positions
|
||||
blinky-start-row
|
||||
blinky-start-col
|
||||
pinky-start-row
|
||||
pinky-start-col
|
||||
inky-start-row
|
||||
inky-start-col
|
||||
clyde-start-row
|
||||
clyde-start-col
|
||||
|
||||
;; Ghost scatter corners
|
||||
blinky-scatter-row
|
||||
blinky-scatter-col
|
||||
pinky-scatter-row
|
||||
pinky-scatter-col
|
||||
inky-scatter-row
|
||||
inky-scatter-col
|
||||
clyde-scatter-row
|
||||
clyde-scatter-col
|
||||
|
||||
;; Ghost house exit delays (ms)
|
||||
pinky-exit-delay
|
||||
inky-exit-delay
|
||||
clyde-exit-delay
|
||||
|
||||
;; Ghost mode durations (ms)
|
||||
scatter-duration-1
|
||||
chase-duration-1
|
||||
scatter-duration-2
|
||||
chase-duration-2
|
||||
scatter-duration-3
|
||||
|
||||
;; Ghost AI
|
||||
clyde-shy-distance
|
||||
pinky-look-ahead
|
||||
|
||||
;; Animation
|
||||
animation-interval-ms
|
||||
@@ -123,9 +168,54 @@
|
||||
(define sprite-scale-pacman 1.5)
|
||||
(define sprite-scale-key 1.5)
|
||||
(define sprite-scale-key-ui 3)
|
||||
(define sprite-scale-ghost 1.5)
|
||||
|
||||
;; Movement speed: time between automatic movement ticks
|
||||
(define pacman-speed-ms 200)
|
||||
(define ghost-speed-ms 220)
|
||||
|
||||
;; Ghost house position (door and exit point above door)
|
||||
(define ghost-house-door-row 12)
|
||||
(define ghost-house-door-col-left 13)
|
||||
(define ghost-house-door-col-right 14)
|
||||
(define ghost-house-exit-row 11)
|
||||
(define ghost-house-exit-col 14)
|
||||
|
||||
;; Ghost start positions
|
||||
(define blinky-start-row 11)
|
||||
(define blinky-start-col 14)
|
||||
(define pinky-start-row 14)
|
||||
(define pinky-start-col 13)
|
||||
(define inky-start-row 14)
|
||||
(define inky-start-col 11)
|
||||
(define clyde-start-row 14)
|
||||
(define clyde-start-col 16)
|
||||
|
||||
;; Ghost scatter target corners
|
||||
(define blinky-scatter-row 0)
|
||||
(define blinky-scatter-col 27)
|
||||
(define pinky-scatter-row 0)
|
||||
(define pinky-scatter-col 0)
|
||||
(define inky-scatter-row 30)
|
||||
(define inky-scatter-col 27)
|
||||
(define clyde-scatter-row 30)
|
||||
(define clyde-scatter-col 0)
|
||||
|
||||
;; Ghost house exit delays (ms) — staggered release
|
||||
(define pinky-exit-delay 2000)
|
||||
(define inky-exit-delay 5000)
|
||||
(define clyde-exit-delay 8000)
|
||||
|
||||
;; Ghost mode durations (ms) — scatter/chase alternation
|
||||
(define scatter-duration-1 7000)
|
||||
(define chase-duration-1 20000)
|
||||
(define scatter-duration-2 7000)
|
||||
(define chase-duration-2 20000)
|
||||
(define scatter-duration-3 5000)
|
||||
|
||||
;; Ghost AI parameters
|
||||
(define clyde-shy-distance 8)
|
||||
(define pinky-look-ahead 2)
|
||||
|
||||
;; Animation timing
|
||||
(define animation-interval-ms 100)
|
||||
|
||||
Reference in New Issue
Block a user