Refactor(Structure): Move ADTs into adt/ folder, rename spel.rkt to main.rkt
New structure groups all ADT modules under adt/ directory, removing redundant adt- prefix from filenames. Library names now read as (pacman-project adt position) etc. All imports updated accordingly. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
;; pixels, windows, or sprites. Grid-to-pixel conversion happens exclusively
|
||||
;; here.
|
||||
|
||||
(define-library (pacman-project adt-draw)
|
||||
(define-library (pacman-project adt draw)
|
||||
(import (scheme base)
|
||||
(pp1 graphics)
|
||||
(pacman-project constants))
|
||||
@@ -194,12 +194,6 @@
|
||||
((pause-tile 'draw-rectangle!) 0 90 670 height "black")
|
||||
((pause-tile 'draw-text!) "Game Paused" 40 200 400 "red"))))
|
||||
|
||||
;; redraw-maze! :: maze -> /
|
||||
;; Redraws the maze (after door removal).
|
||||
(define (redraw-maze! maze)
|
||||
((maze-tile 'clear!))
|
||||
(draw-maze! maze))
|
||||
|
||||
;;
|
||||
;; Main draw function
|
||||
;;
|
||||
@@ -7,11 +7,11 @@
|
||||
;; Top-level game object that connects the level (logic) with the draw ADT
|
||||
;; (graphics). Registers callbacks for the game loop, keys, and drawing.
|
||||
|
||||
(define-library (pacman-project adt-game)
|
||||
(define-library (pacman-project adt game)
|
||||
(import (scheme base)
|
||||
(pacman-project constants)
|
||||
(pacman-project adt-level)
|
||||
(pacman-project adt-draw))
|
||||
(pacman-project adt level)
|
||||
(pacman-project adt draw))
|
||||
(export make-game)
|
||||
|
||||
(begin
|
||||
@@ -9,10 +9,10 @@
|
||||
;; The key is placed at a random coin position in the maze. When Pac-Man
|
||||
;; picks it up, doors can be opened. Contains NO graphics code.
|
||||
|
||||
(define-library (pacman-project adt-key)
|
||||
(define-library (pacman-project adt key)
|
||||
(import (scheme base)
|
||||
(pacman-project constants)
|
||||
(pacman-project adt-position))
|
||||
(pacman-project adt position))
|
||||
(export make-key)
|
||||
|
||||
(begin
|
||||
@@ -8,15 +8,15 @@
|
||||
;; pickup, door opening, teleportation, pause, and time management.
|
||||
;; Contains NO graphics code.
|
||||
|
||||
(define-library (pacman-project adt-level)
|
||||
(define-library (pacman-project adt level)
|
||||
(import (scheme base)
|
||||
(pacman-project constants)
|
||||
(pacman-project adt-position)
|
||||
(pacman-project adt-maze)
|
||||
(pacman-project adt-pacman)
|
||||
(pacman-project adt-key)
|
||||
(pacman-project adt-score)
|
||||
(pacman-project adt-timer))
|
||||
(pacman-project adt position)
|
||||
(pacman-project adt maze)
|
||||
(pacman-project adt pacman)
|
||||
(pacman-project adt key)
|
||||
(pacman-project adt score)
|
||||
(pacman-project adt timer))
|
||||
(export make-level)
|
||||
|
||||
(begin
|
||||
@@ -7,7 +7,7 @@
|
||||
;; The maze contains the logical grid with cells. Each cell has a type
|
||||
;; (wall, coin, empty, key, door). This ADT contains NO graphics code.
|
||||
|
||||
(define-library (pacman-project adt-maze)
|
||||
(define-library (pacman-project adt maze)
|
||||
(import (scheme base)
|
||||
(pacman-project constants))
|
||||
(export make-maze)
|
||||
@@ -7,9 +7,9 @@
|
||||
;; Manages the logical state of the player: grid position and current
|
||||
;; direction. Contains NO graphics code.
|
||||
|
||||
(define-library (pacman-project adt-pacman)
|
||||
(define-library (pacman-project adt pacman)
|
||||
(import (scheme base)
|
||||
(pacman-project adt-position))
|
||||
(pacman-project adt position))
|
||||
(export make-pacman)
|
||||
|
||||
(begin
|
||||
@@ -7,7 +7,7 @@
|
||||
;; A position represents a location on the logical maze grid.
|
||||
;; Coordinates are in grid units (row, col), NOT pixels.
|
||||
|
||||
(define-library (pacman-project adt-position)
|
||||
(define-library (pacman-project adt position)
|
||||
(import (scheme base))
|
||||
(export make-position)
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
;; Tracks the player's score. Contains NO graphics code.
|
||||
|
||||
(define-library (pacman-project adt-score)
|
||||
(define-library (pacman-project adt score)
|
||||
(import (scheme base)
|
||||
(pacman-project constants))
|
||||
(export make-score)
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
;; Manages the countdown time limit. Contains NO graphics code.
|
||||
|
||||
(define-library (pacman-project adt-timer)
|
||||
(define-library (pacman-project adt timer)
|
||||
(import (scheme base)
|
||||
(pacman-project constants))
|
||||
(export make-timer)
|
||||
@@ -5,7 +5,7 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(import (scheme base)
|
||||
(pacman-project adt-game))
|
||||
(pacman-project adt game))
|
||||
|
||||
(define game (make-game))
|
||||
((game 'start!))
|
||||
@@ -8,7 +8,7 @@
|
||||
(import (scheme base)
|
||||
(pp1 tests)
|
||||
(pacman-project constants)
|
||||
(pacman-project adt-maze))
|
||||
(pacman-project adt maze))
|
||||
(export test)
|
||||
|
||||
(begin
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
(define-library (pacman-project tests test-pacman)
|
||||
(import (scheme base)
|
||||
(pp1 tests)
|
||||
(pacman-project adt-position)
|
||||
(pacman-project adt-pacman))
|
||||
(pacman-project adt position)
|
||||
(pacman-project adt pacman))
|
||||
(export test)
|
||||
|
||||
(begin
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
(define-library (pacman-project tests test-position)
|
||||
(import (scheme base)
|
||||
(pp1 tests)
|
||||
(pacman-project adt-position))
|
||||
(pacman-project adt position))
|
||||
(export test)
|
||||
|
||||
(begin
|
||||
|
||||
30
pacman-project/tests/test-score.rkt
Normal file
30
pacman-project/tests/test-score.rkt
Normal file
@@ -0,0 +1,30 @@
|
||||
#lang r7rs
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Tests: Score ADT ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(define-library (pacman-project tests test-score)
|
||||
(import (scheme base)
|
||||
(pp1 tests)
|
||||
(pacman-project adt score))
|
||||
(export test)
|
||||
|
||||
(begin
|
||||
|
||||
;; Test initial score
|
||||
(define (test-initial)
|
||||
(define s (make-score))
|
||||
(check-eq? (s 'points) 0 "Initial score should be 0"))
|
||||
|
||||
;; Test score increase
|
||||
(define (test-increase)
|
||||
(define s (make-score))
|
||||
((s 'increase!))
|
||||
(check-eq? (s 'points) 10 "Score should be 10 after 1 coin")
|
||||
((s 'increase!))
|
||||
(check-eq? (s 'points) 20 "Score should be 20 after 2 coins"))
|
||||
|
||||
(define (test)
|
||||
(run-test test-initial "Score: initial score")
|
||||
(run-test test-increase "Score: increase"))))
|
||||
@@ -7,7 +7,7 @@
|
||||
(define-library (pacman-project tests test-timer)
|
||||
(import (scheme base)
|
||||
(pp1 tests)
|
||||
(pacman-project adt-timer))
|
||||
(pacman-project adt timer))
|
||||
(export test)
|
||||
|
||||
(begin
|
||||
|
||||
Reference in New Issue
Block a user