aboutsummaryrefslogtreecommitdiff
path: root/tests/renderer-test.scm
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 /tests/renderer-test.scm
parent5de3b9cf122542f2a0c1c906c8ce8add20e5c8c6 (diff)
Convert entities to alists
Diffstat (limited to 'tests/renderer-test.scm')
-rw-r--r--tests/renderer-test.scm31
1 files changed, 18 insertions, 13 deletions
diff --git a/tests/renderer-test.scm b/tests/renderer-test.scm
index 2829348..9f6ce55 100644
--- a/tests/renderer-test.scm
+++ b/tests/renderer-test.scm
@@ -42,6 +42,11 @@
(include "entity.scm")
(import downstroke-entity)
+(import (only (list-utils alist) plist->alist))
+
+;; Test helper: build an alist entity from plist-style keyword args.
+(define (entity . kws) (plist->alist kws))
+
;; Load world module
(include "world.scm")
(import downstroke-world)
@@ -54,7 +59,7 @@
(test-group "entity-screen-coords"
(let* ((cam (make-camera x: 10 y: 20))
- (e (list #:x 50 #:y 80 #:width 16 #:height 16)))
+ (e (entity #:x 50 #:y 80 #:width 16 #:height 16)))
(test-equal "subtracts camera offset from x"
40
(car (entity-screen-coords e cam)))
@@ -69,7 +74,7 @@
(cadddr (entity-screen-coords e cam))))
(let* ((cam (make-camera x: 0 y: 0))
- (e (list #:x 100.7 #:y 200.3 #:width 16 #:height 16)))
+ (e (entity #:x 100.7 #:y 200.3 #:width 16 #:height 16)))
(test-equal "floors fractional x"
100
(car (entity-screen-coords e cam)))
@@ -78,7 +83,7 @@
(cadr (entity-screen-coords e cam))))
(let* ((cam (make-camera x: 0 y: 0))
- (e (list #:x 0 #:y 0 #:width 32 #:height 32)))
+ (e (entity #:x 0 #:y 0 #:width 32 #:height 32)))
(test-equal "zero camera, zero position"
'(0 0 32 32)
(entity-screen-coords e cam))))
@@ -86,13 +91,13 @@
(test-group "entity-flip"
(test-equal "facing 1: no flip"
'()
- (entity-flip (list #:facing 1)))
+ (entity-flip (entity #:facing 1)))
(test-equal "facing -1: horizontal flip"
'(horizontal)
- (entity-flip (list #:facing -1)))
+ (entity-flip (entity #:facing -1)))
(test-equal "no facing key: defaults to no flip"
'()
- (entity-flip (list #:x 0))))
+ (entity-flip (entity #:x 0))))
(test-group "render-scene!"
(let* ((cam (make-camera x: 0 y: 0))
@@ -116,7 +121,7 @@
(begin (render-scene! #f scene) #t)))
(let* ((cam (make-camera x: 0 y: 0))
- (box (list #:x 4 #:y 8 #:width 10 #:height 12 #:color '(200 40 90)))
+ (box (entity #:x 4 #:y 8 #:width 10 #:height 12 #:color '(200 40 90)))
(scene (make-scene entities: (list box)
tilemap: #f
camera: cam
@@ -243,8 +248,8 @@
tileset: tileset
layers: (list layer)
objects: '()))
- (player (list #:type 'player #:x 10 #:y 20 #:width 16 #:height 16 #:facing 1))
- (enemy (list #:type 'enemy #:x 50 #:y 60 #:width 16 #:height 16 #:facing -1))
+ (player (entity #:type 'player #:x 10 #:y 20 #:width 16 #:height 16 #:facing 1))
+ (enemy (entity #:type 'enemy #:x 50 #:y 60 #:width 16 #:height 16 #:facing -1))
(scene (make-scene entities: (list player enemy)
tilemap: tilemap
camera: cam
@@ -267,7 +272,7 @@
tileset: tileset
layers: (list layer)
objects: '()))
- (player (list #:type 'player #:x 10 #:y 20 #:width 16 #:height 16 #:facing 1))
+ (player (entity #:type 'player #:x 10 #:y 20 #:width 16 #:height 16 #:facing 1))
(scene (make-scene entities: (list player)
tilemap: tilemap
camera: cam
@@ -287,9 +292,9 @@
tileset-source: "" tileset: tileset
layers: (list layer) objects: '()))
(tex 'mock-texture)
- (entity (list #:type 'box #:x 10 #:y 20 #:width 16 #:height 16 #:tile-id 1))
- (cell (vector entity 'extra-data 0 100 'linear #t))
- (scene-ok (make-scene entities: (list entity)
+ (ent (entity #:type 'box #:x 10 #:y 20 #:width 16 #:height 16 #:tile-id 1))
+ (cell (vector ent 'extra-data 0 100 'linear #t))
+ (scene-ok (make-scene entities: (list ent)
tilemap: tilemap camera: cam
tileset-texture: tex camera-target: #f))
(scene-bad (make-scene entities: (list cell)