Renamed files: constanten→constants, adt-positie→adt-position, adt-doolhof→adt-maze, adt-sleutel→adt-key, adt-tijdslimiet→adt-timer, adt-teken→adt-draw, adt-spel→adt-game. All message names, variables, comments, and tests converted to English. Also fixed counter location bug (time-label x/y were swapped). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
135 lines
3.2 KiB
Racket
135 lines
3.2 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
|
|
|
|
;; Sprites
|
|
sprite-scale-pacman
|
|
sprite-scale-key
|
|
sprite-scale-key-ui
|
|
|
|
;; 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
|
|
|
|
;; UI positions
|
|
score-text-size
|
|
score-text-x
|
|
score-text-y
|
|
time-text-size
|
|
time-label-x
|
|
time-label-y
|
|
time-value-x
|
|
time-value-y
|
|
separator-x
|
|
separator-width
|
|
key-ui-x
|
|
key-ui-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: inset in pixels from cell edge
|
|
(define coin-inset 7)
|
|
|
|
;; Sprite scale factors
|
|
(define sprite-scale-pacman 1.5)
|
|
(define sprite-scale-key 1.5)
|
|
(define sprite-scale-key-ui 3)
|
|
|
|
;; 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)
|
|
|
|
;; UI positions for score display
|
|
(define score-text-size 40)
|
|
(define score-text-x 560)
|
|
(define score-text-y 20)
|
|
|
|
;; UI positions for time display (right side of separator)
|
|
(define time-text-size 35)
|
|
(define time-label-x 710)
|
|
(define time-label-y 300)
|
|
(define time-value-x 800)
|
|
(define time-value-y 400)
|
|
|
|
;; Separator line between play field and UI
|
|
(define separator-x 670)
|
|
(define separator-width 24)
|
|
|
|
;; Key UI position (next to score)
|
|
(define key-ui-x 20)
|
|
(define key-ui-y 35)))
|