From 8251c85a4a588504d38a2fad05e4b0fe1cdccb9d Mon Sep 17 00:00:00 2001 From: Gene Pasquet Date: Fri, 17 Apr 2026 16:30:34 +0100 Subject: Convert entities to alists --- demo/shmup.scm | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'demo/shmup.scm') diff --git a/demo/shmup.scm b/demo/shmup.scm index 315069c..15afb71 100644 --- a/demo/shmup.scm +++ b/demo/shmup.scm @@ -3,6 +3,7 @@ (chicken random) (only srfi-1 filter any) (only srfi-197 chain) + (only (list-utils alist) plist->alist) (prefix sdl2 "sdl2:") (prefix sdl2-ttf "ttf:") (prefix sdl2-image "img:") @@ -27,16 +28,16 @@ ;; ── Entity factories ───────────────────────────────────────────────────────── (define (make-player) - (list #:type 'player #:x 280 #:y 360 - #:width 16 #:height 16 #:vx 0 #:vy 0)) + (plist->alist (list #:type 'player #:x 280 #:y 360 + #:width 16 #:height 16 #:vx 0 #:vy 0))) (define (make-bullet x y) - (list #:type 'bullet #:x x #:y y - #:width 4 #:height 8 #:vx 0 #:vy -6)) + (plist->alist (list #:type 'bullet #:x x #:y y + #:width 4 #:height 8 #:vx 0 #:vy -6))) (define (make-enemy x) - (list #:type 'enemy #:x x #:y 0 - #:width 16 #:height 16 #:vx 0 #:vy 2)) + (plist->alist (list #:type 'enemy #:x x #:y 0 + #:width 16 #:height 16 #:vx 0 #:vy 2))) ;; ── Collision ──────────────────────────────────────────────────────────────── @@ -79,7 +80,7 @@ (define (update-player player input) (let ((updated (chain player (entity-set _ #:vx (player-vx input)) - (apply-velocity-x _ #f 0) + (apply-velocity-x #f _ 0) (clamp-player-x _)))) (when (input-pressed? input 'a) (play-sound 'shoot)) -- cgit v1.2.3