Refactor(Constanten): Extract all magic numbers into centralized constants file
All hardcoded values (cell sizes, offsets, sprite scales, timing, score, UI positions, cell type codes) are now named constants in an R7RS library. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
135
pacman-project/constanten.rkt
Normal file
135
pacman-project/constanten.rkt
Normal file
@@ -0,0 +1,135 @@
|
|||||||
|
#lang r7rs
|
||||||
|
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
;; Constanten ;;
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
|
;; Alle configuratieconstanten voor het Pac-Man spel worden hier gedefinieerd.
|
||||||
|
;; Dit voorkomt "magic constants" doorheen de code en maakt het spel flexibel
|
||||||
|
;; aanpasbaar.
|
||||||
|
|
||||||
|
(define-library (pacman-project constanten)
|
||||||
|
(import (scheme base))
|
||||||
|
(export ;; Venster
|
||||||
|
venster-breedte-px
|
||||||
|
venster-hoogte-px
|
||||||
|
|
||||||
|
;; Doolhof grid
|
||||||
|
cel-grootte-px
|
||||||
|
doolhof-offset-y
|
||||||
|
doolhof-muur-krimp
|
||||||
|
|
||||||
|
;; Cel types
|
||||||
|
cel-type-muntje
|
||||||
|
cel-type-muur
|
||||||
|
cel-type-leeg
|
||||||
|
cel-type-sleutel
|
||||||
|
cel-type-deur
|
||||||
|
|
||||||
|
;; Muntje weergave
|
||||||
|
muntje-inset
|
||||||
|
|
||||||
|
;; Sprites
|
||||||
|
sprite-schaal-pacman
|
||||||
|
sprite-schaal-sleutel
|
||||||
|
sprite-schaal-sleutel-ui
|
||||||
|
|
||||||
|
;; Animatie
|
||||||
|
animatie-interval-ms
|
||||||
|
|
||||||
|
;; Score
|
||||||
|
punten-per-muntje
|
||||||
|
|
||||||
|
;; Tijdslimiet
|
||||||
|
start-tijd-seconden
|
||||||
|
ms-per-seconde
|
||||||
|
tijd-bonus-per-muntje
|
||||||
|
|
||||||
|
;; Sleutel plaatsing
|
||||||
|
max-plaatsing-pogingen
|
||||||
|
|
||||||
|
;; Rotatie hoeken
|
||||||
|
rotatie-rechts
|
||||||
|
rotatie-links
|
||||||
|
rotatie-omhoog
|
||||||
|
rotatie-omlaag
|
||||||
|
|
||||||
|
;; UI posities
|
||||||
|
score-tekst-grootte
|
||||||
|
score-tekst-x
|
||||||
|
score-tekst-y
|
||||||
|
tijd-tekst-grootte
|
||||||
|
tijd-label-x
|
||||||
|
tijd-label-y
|
||||||
|
tijd-waarde-x
|
||||||
|
tijd-waarde-y
|
||||||
|
scheidingslijn-x
|
||||||
|
scheidingslijn-breedte
|
||||||
|
sleutel-ui-x
|
||||||
|
sleutel-ui-y)
|
||||||
|
|
||||||
|
(begin
|
||||||
|
|
||||||
|
;; Venster dimensies
|
||||||
|
(define venster-breedte-px 1000)
|
||||||
|
(define venster-hoogte-px 830)
|
||||||
|
|
||||||
|
;; Doolhof grid configuratie
|
||||||
|
(define cel-grootte-px 24)
|
||||||
|
(define doolhof-offset-y 97)
|
||||||
|
(define doolhof-muur-krimp 6)
|
||||||
|
|
||||||
|
;; Cel type encodering voor het doolhof grid
|
||||||
|
(define cel-type-muntje 0)
|
||||||
|
(define cel-type-muur 1)
|
||||||
|
(define cel-type-leeg 2)
|
||||||
|
(define cel-type-sleutel 3)
|
||||||
|
(define cel-type-deur 4)
|
||||||
|
|
||||||
|
;; Muntje weergave: inset in pixels ten opzichte van cel rand
|
||||||
|
(define muntje-inset 7)
|
||||||
|
|
||||||
|
;; Sprite schaalfactoren
|
||||||
|
(define sprite-schaal-pacman 1.5)
|
||||||
|
(define sprite-schaal-sleutel 1.5)
|
||||||
|
(define sprite-schaal-sleutel-ui 3)
|
||||||
|
|
||||||
|
;; Animatie timing
|
||||||
|
(define animatie-interval-ms 100)
|
||||||
|
|
||||||
|
;; Score configuratie
|
||||||
|
(define punten-per-muntje 10)
|
||||||
|
|
||||||
|
;; Tijdslimiet configuratie
|
||||||
|
(define start-tijd-seconden 60)
|
||||||
|
(define ms-per-seconde 1000)
|
||||||
|
(define tijd-bonus-per-muntje 1)
|
||||||
|
|
||||||
|
;; Sleutel plaatsing
|
||||||
|
(define max-plaatsing-pogingen 1000)
|
||||||
|
|
||||||
|
;; Rotatie hoeken (graden)
|
||||||
|
(define rotatie-rechts 0)
|
||||||
|
(define rotatie-links 180)
|
||||||
|
(define rotatie-omhoog 90)
|
||||||
|
(define rotatie-omlaag -90)
|
||||||
|
|
||||||
|
;; UI posities voor score weergave
|
||||||
|
(define score-tekst-grootte 40)
|
||||||
|
(define score-tekst-x 560)
|
||||||
|
(define score-tekst-y 20)
|
||||||
|
|
||||||
|
;; UI posities voor tijd weergave
|
||||||
|
(define tijd-tekst-grootte 35)
|
||||||
|
(define tijd-label-x 300)
|
||||||
|
(define tijd-label-y 710)
|
||||||
|
(define tijd-waarde-x 400)
|
||||||
|
(define tijd-waarde-y 800)
|
||||||
|
|
||||||
|
;; Scheidingslijn tussen speelveld en UI
|
||||||
|
(define scheidingslijn-x 670)
|
||||||
|
(define scheidingslijn-breedte 24)
|
||||||
|
|
||||||
|
;; Sleutel UI positie (naast score)
|
||||||
|
(define sleutel-ui-x 20)
|
||||||
|
(define sleutel-ui-y 35)))
|
||||||
Reference in New Issue
Block a user