aboutsummaryrefslogtreecommitdiff
path: root/demo
diff options
context:
space:
mode:
authorGene Pasquet <dev@etenil.net>2026-04-17 16:30:34 +0100
committerGene Pasquet <dev@etenil.net>2026-04-17 16:30:34 +0100
commit8251c85a4a588504d38a2fad05e4b0fe1cdccb9d (patch)
treec3fcedb7331caf798f2355c7549b35aa3aaf6ac8 /demo
parent5de3b9cf122542f2a0c1c906c8ce8add20e5c8c6 (diff)
Convert entities to alists
Diffstat (limited to 'demo')
-rw-r--r--demo/animation.scm15
-rw-r--r--demo/platformer.scm13
-rw-r--r--demo/sandbox.scm27
-rw-r--r--demo/scaling.scm15
-rw-r--r--demo/shmup.scm15
-rw-r--r--demo/topdown.scm13
-rw-r--r--demo/tweens.scm23
7 files changed, 65 insertions, 56 deletions
diff --git a/demo/animation.scm b/demo/animation.scm
index 2379115..f2048d6 100644
--- a/demo/animation.scm
+++ b/demo/animation.scm
@@ -2,6 +2,7 @@
(chicken base)
(chicken pretty-print)
(only srfi-1 iota)
+ (only (list-utils alist) plist->alist)
(prefix sdl2 "sdl2:")
(prefix sdl2-ttf "ttf:")
downstroke-engine
@@ -19,13 +20,13 @@
(define *title-font* #f)
(define (make-demo-entity x y tw th id)
- (list #:type 'demo-bot
- #:x x #:y y #:width tw #:height th
- #:vx 0 #:vy 0
- #:gravity? #t #:on-ground? #f
- #:solid? #t #:immovable? #f
- #:tile-id 1
- #:demo-id id #:demo-since-jump 0))
+ (plist->alist (list #:type 'demo-bot
+ #:x x #:y y #:width tw #:height th
+ #:vx 0 #:vy 0
+ #:gravity? #t #:on-ground? #f
+ #:solid? #t #:immovable? #f
+ #:tile-id 1
+ #:demo-id id #:demo-since-jump 0)))
(define (make-demo-tilemap ts tw th gw gh)
(let* ((ncols (inexact->exact (ceiling (/ gw tw))))
diff --git a/demo/platformer.scm b/demo/platformer.scm
index 1a24a8f..6e854fe 100644
--- a/demo/platformer.scm
+++ b/demo/platformer.scm
@@ -1,6 +1,7 @@
(import scheme
(chicken base)
(chicken process-context)
+ (only (list-utils alist) plist->alist)
(prefix sdl2 "sdl2:")
(prefix sdl2-ttf "ttf:")
(prefix sdl2-image "img:")
@@ -16,12 +17,12 @@
(define +debug?+ (and (member "--debug" (command-line-arguments)) #t))
(define (make-player)
- (list #:type 'player
- #:x 100 #:y 50
- #:width 16 #:height 16
- #:vx 0 #:vy 0
- #:gravity? #t #:on-ground? #f
- #:tile-id 1 #:tags '(player)))
+ (plist->alist (list #:type 'player
+ #:x 100 #:y 50
+ #:width 16 #:height 16
+ #:vx 0 #:vy 0
+ #:gravity? #t #:on-ground? #f
+ #:tile-id 1 #:tags '(player))))
(define (player-vx input)
(cond ((input-held? input 'left) -3)
diff --git a/demo/sandbox.scm b/demo/sandbox.scm
index e23584f..ef71053 100644
--- a/demo/sandbox.scm
+++ b/demo/sandbox.scm
@@ -2,6 +2,7 @@
(chicken base)
(chicken random)
(only srfi-1 iota take)
+ (only (list-utils alist) plist->alist)
(prefix sdl2 "sdl2:")
(prefix sdl2-ttf "ttf:")
(prefix sdl2-image "img:")
@@ -49,12 +50,12 @@
;; ── Entity factories ─────────────────────────────────────────────────────────
(define (make-box x y tw th)
- (list #:type 'box
- #:x x #:y y #:width tw #:height th
- #:vx 0 #:vy 0
- #:gravity? #t #:on-ground? #f
- #:solid? #t #:immovable? #f
- #:tile-id 29))
+ (plist->alist (list #:type 'box
+ #:x x #:y y #:width tw #:height th
+ #:vx 0 #:vy 0
+ #:gravity? #t #:on-ground? #f
+ #:solid? #t #:immovable? #f
+ #:tile-id 29)))
(define (spawn-boxes tw th)
(map (lambda (i)
@@ -64,13 +65,13 @@
(iota 8)))
(define (make-demo-bot x y tw th id)
- (list #:type 'demo-bot
- #:x x #:y y #:width tw #:height th
- #:vx 0 #:vy 0
- #:gravity? #t #:on-ground? #f
- #:solid? #t #:immovable? #f
- #:tile-id 1
- #:demo-id id #:demo-since-jump 0))
+ (plist->alist (list #:type 'demo-bot
+ #:x x #:y y #:width tw #:height th
+ #:vx 0 #:vy 0
+ #:gravity? #t #:on-ground? #f
+ #:solid? #t #:immovable? #f
+ #:tile-id 1
+ #:demo-id id #:demo-since-jump 0)))
;; ── Per-entity intent ───────────────────────────────────────────────────────
diff --git a/demo/scaling.scm b/demo/scaling.scm
index 982817a..1d74e6a 100644
--- a/demo/scaling.scm
+++ b/demo/scaling.scm
@@ -1,5 +1,6 @@
(import scheme
(chicken base)
+ (only (list-utils alist) plist->alist)
(prefix sdl2 "sdl2:")
(prefix sdl2-ttf "ttf:")
downstroke-engine
@@ -25,13 +26,13 @@
create: (lambda (game)
(game-scene-set! game
(make-scene
- entities: (list (list #:type 'box
- #:x (/ +width+ 2)
- #:y (/ +height+ 2)
- #:width +box-size+
- #:height +box-size+
- #:vx 0 #:vy 0
- #:color '(255 200 0)))
+ entities: (list (plist->alist (list #:type 'box
+ #:x (/ +width+ 2)
+ #:y (/ +height+ 2)
+ #:width +box-size+
+ #:height +box-size+
+ #:vx 0 #:vy 0
+ #:color '(255 200 0))))
tilemap: #f
camera: (make-camera x: 0 y: 0)
tileset-texture: #f
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))
diff --git a/demo/topdown.scm b/demo/topdown.scm
index 7fa9b7e..21c7b6f 100644
--- a/demo/topdown.scm
+++ b/demo/topdown.scm
@@ -2,6 +2,7 @@
(chicken base)
srfi-8
(only srfi-197 chain)
+ (only (list-utils alist) plist->alist)
(prefix sdl2 "sdl2:")
(prefix sdl2-ttf "ttf:")
(prefix sdl2-image "img:")
@@ -13,12 +14,12 @@
downstroke-scene-loader)
(define (make-player)
- (list #:type 'player
- #:x 100 #:y 100
- #:width 16 #:height 16
- #:vx 0 #:vy 0
- #:gravity? #f
- #:tile-id 1 #:tags '(player)))
+ (plist->alist (list #:type 'player
+ #:x 100 #:y 100
+ #:width 16 #:height 16
+ #:vx 0 #:vy 0
+ #:gravity? #f
+ #:tile-id 1 #:tags '(player))))
(define (input->velocity input)
(values (+ (if (input-held? input 'left) -3 0)
diff --git a/demo/tweens.scm b/demo/tweens.scm
index 609c541..51a72b2 100644
--- a/demo/tweens.scm
+++ b/demo/tweens.scm
@@ -1,12 +1,14 @@
(import scheme
(chicken base)
(only srfi-1 iota)
+ (only (list-utils alist) plist->alist)
(prefix sdl2 "sdl2:")
(prefix sdl2-ttf "ttf:")
downstroke-engine
downstroke-world
downstroke-renderer
- downstroke-entity)
+ downstroke-entity
+ downstroke-tween)
;; ── Constants ────────────────────────────────────────────────────────────────
@@ -31,15 +33,16 @@
(define (make-ease-entity ease-sym y rgb)
(let* ((left 20)
(right (+ left 120))
- (base (list #:x left #:y y)))
- (list #:type 'tween-demo #:x left #:y y
- #:width 14 #:height 14
- #:vx 0 #:vy 0 #:gravity? #f #:solid? #f
- #:color rgb
- #:ease-name ease-sym
- #:tween (make-tween base props: `((#:x . ,right))
- duration: +ease-duration+ ease: ease-sym
- repeat: -1 yoyo?: #t))))
+ (base (plist->alist (list #:x left #:y y))))
+ (plist->alist
+ (list #:type 'tween-demo #:x left #:y y
+ #:width 14 #:height 14
+ #:vx 0 #:vy 0 #:gravity? #f #:solid? #f
+ #:color rgb
+ #:ease-name ease-sym
+ #:tween (make-tween base props: `((#:x . ,right))
+ duration: +ease-duration+ ease: ease-sym
+ repeat: -1 yoyo?: #t)))))
;; ── Rendering ────────────────────────────────────────────────────────────────