- Named color constants (arcade blue walls, golden coins, pink doors) - Header bar layout with PAC-MAN title, score label, key indicator - Sidebar time display with label and large value - Game over and pause overlay positions - Smaller round-looking coins (coin-size + coin-inset) - Removed old magic position values Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
201 lines
4.9 KiB
Racket
201 lines
4.9 KiB
Racket
#lang r7rs
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
;; Constants ;;
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; All configuration constants for the Pac-Man game. Prevents magic numbers
|
|
;; throughout the codebase and makes the game easily configurable.
|
|
|
|
(define-library (pacman-project constants)
|
|
(import (scheme base))
|
|
(export ;; Window
|
|
window-width-px
|
|
window-height-px
|
|
|
|
;; Maze grid
|
|
cell-size-px
|
|
maze-offset-y
|
|
maze-wall-shrink
|
|
|
|
;; Cell types
|
|
cell-type-coin
|
|
cell-type-wall
|
|
cell-type-empty
|
|
cell-type-key
|
|
cell-type-door
|
|
|
|
;; Coin rendering
|
|
coin-inset
|
|
coin-size
|
|
|
|
;; Sprites
|
|
sprite-scale-pacman
|
|
sprite-scale-key
|
|
sprite-scale-key-ui
|
|
|
|
;; Movement
|
|
pacman-speed-ms
|
|
|
|
;; Animation
|
|
animation-interval-ms
|
|
|
|
;; Score
|
|
points-per-coin
|
|
|
|
;; Time limit
|
|
start-time-seconds
|
|
ms-per-second
|
|
time-bonus-per-coin
|
|
|
|
;; Key placement
|
|
max-placement-attempts
|
|
|
|
;; Rotation angles
|
|
rotation-right
|
|
rotation-left
|
|
rotation-up
|
|
rotation-down
|
|
|
|
;; Colors
|
|
color-background
|
|
color-wall
|
|
color-door
|
|
color-coin
|
|
color-text
|
|
color-title
|
|
color-header-bg
|
|
color-game-over
|
|
color-pause-bg
|
|
color-pause-text
|
|
|
|
;; UI layout
|
|
header-height
|
|
header-title-size
|
|
header-title-x
|
|
header-title-y
|
|
score-label-size
|
|
score-label-x
|
|
score-label-y
|
|
score-value-size
|
|
score-value-x
|
|
score-value-y
|
|
key-ui-x
|
|
key-ui-y
|
|
sidebar-x
|
|
sidebar-width
|
|
time-label-size
|
|
time-label-x
|
|
time-label-y
|
|
time-value-size
|
|
time-value-x
|
|
time-value-y
|
|
game-over-text-size
|
|
game-over-text-x
|
|
game-over-text-y
|
|
pause-text-size
|
|
pause-text-x
|
|
pause-text-y)
|
|
|
|
(begin
|
|
|
|
;; Window dimensions
|
|
(define window-width-px 1000)
|
|
(define window-height-px 830)
|
|
|
|
;; Maze grid configuration
|
|
(define cell-size-px 24)
|
|
(define maze-offset-y 97)
|
|
(define maze-wall-shrink 6)
|
|
|
|
;; Cell type encoding for the maze grid
|
|
(define cell-type-coin 0)
|
|
(define cell-type-wall 1)
|
|
(define cell-type-empty 2)
|
|
(define cell-type-key 3)
|
|
(define cell-type-door 4)
|
|
|
|
;; Coin rendering
|
|
(define coin-inset 9)
|
|
(define coin-size 6)
|
|
|
|
;; Sprite scale factors
|
|
(define sprite-scale-pacman 1.5)
|
|
(define sprite-scale-key 1.5)
|
|
(define sprite-scale-key-ui 3)
|
|
|
|
;; Movement speed: time between automatic movement ticks
|
|
(define pacman-speed-ms 200)
|
|
|
|
;; Animation timing
|
|
(define animation-interval-ms 100)
|
|
|
|
;; Score configuration
|
|
(define points-per-coin 10)
|
|
|
|
;; Time limit configuration
|
|
(define start-time-seconds 60)
|
|
(define ms-per-second 1000)
|
|
(define time-bonus-per-coin 1)
|
|
|
|
;; Key placement
|
|
(define max-placement-attempts 1000)
|
|
|
|
;; Rotation angles (degrees)
|
|
(define rotation-right 0)
|
|
(define rotation-left 180)
|
|
(define rotation-up 90)
|
|
(define rotation-down -90)
|
|
|
|
;; Colors — arcade-style palette
|
|
(define color-background "black")
|
|
(define color-wall "#2121DE")
|
|
(define color-door "#FFB8FF")
|
|
(define color-coin "#FFB851")
|
|
(define color-text "white")
|
|
(define color-title "#FFFF00")
|
|
(define color-header-bg "#111111")
|
|
(define color-game-over "#FF0000")
|
|
(define color-pause-bg "black")
|
|
(define color-pause-text "#FF0000")
|
|
|
|
;; UI layout — header bar at the top
|
|
(define header-height 90)
|
|
(define header-title-size 36)
|
|
(define header-title-x 250)
|
|
(define header-title-y 25)
|
|
|
|
;; Score display (left side of header)
|
|
(define score-label-size 20)
|
|
(define score-label-x 20)
|
|
(define score-label-y 25)
|
|
(define score-value-size 32)
|
|
(define score-value-x 20)
|
|
(define score-value-y 50)
|
|
|
|
;; Key UI indicator position
|
|
(define key-ui-x 600)
|
|
(define key-ui-y 30)
|
|
|
|
;; Sidebar (right of maze)
|
|
(define sidebar-x 672)
|
|
(define sidebar-width 4)
|
|
|
|
;; Time display (right sidebar area)
|
|
(define time-label-size 20)
|
|
(define time-label-x 700)
|
|
(define time-label-y 200)
|
|
(define time-value-size 40)
|
|
(define time-value-x 710)
|
|
(define time-value-y 240)
|
|
|
|
;; Game over overlay
|
|
(define game-over-text-size 48)
|
|
(define game-over-text-x 180)
|
|
(define game-over-text-y 380)
|
|
|
|
;; Pause overlay
|
|
(define pause-text-size 48)
|
|
(define pause-text-x 200)
|
|
(define pause-text-y 400)))
|