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:
joren
2026-03-23 11:11:08 +01:00
parent cd70055bc7
commit caac996acd
15 changed files with 55 additions and 31 deletions

View File

@@ -0,0 +1,46 @@
#lang r7rs
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Pac-Man ADT ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Manages the logical state of the player: grid position and current
;; direction. Contains NO graphics code.
(define-library (pacman-project adt pacman)
(import (scheme base)
(pacman-project adt position))
(export make-pacman)
(begin
;; make-pacman :: number, number -> pacman
;; Creates a Pac-Man object at the given start position (row, col).
(define (make-pacman start-row start-col)
(let ((position (make-position start-row start-col))
(direction 'right))
;; position! :: position -> /
(define (position! new-position)
(set! position new-position))
;; direction! :: symbol -> /
(define (direction! new-direction)
(set! direction new-direction))
;; move! :: number, number -> /
;; Moves Pac-Man by a delta on the grid.
(define (move! delta-row delta-col)
((position 'row!) (+ (position 'row) delta-row))
((position 'col!) (+ (position 'col) delta-col)))
;; dispatch-pacman :: symbol -> any
(define (dispatch-pacman msg)
(cond ((eq? msg 'position) position)
((eq? msg 'position!) position!)
((eq? msg 'direction) direction)
((eq? msg 'direction!) direction!)
((eq? msg 'move!) move!)
(else (error "Pac-Man ADT -- Unknown message:" msg))))
dispatch-pacman))))