aboutsummaryrefslogtreecommitdiff
path: root/tests/physics-test.scm
diff options
context:
space:
mode:
authorGene Pasquet <dev@etenil.net>2026-04-06 03:41:09 +0100
committerGene Pasquet <dev@etenil.net>2026-04-06 03:41:09 +0100
commit78a924defabc862a7cfa5476091152c1ef5333ee (patch)
tree5e7e13ca27848dfe87ecf3eb82689d8e9488beb3 /tests/physics-test.scm
parentc4ebbbdd1a0bd081a2ed9447ba8188d97ae54717 (diff)
Fixes, updated license
Diffstat (limited to 'tests/physics-test.scm')
-rw-r--r--tests/physics-test.scm11
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/physics-test.scm b/tests/physics-test.scm
index 858dec8..67c8377 100644
--- a/tests/physics-test.scm
+++ b/tests/physics-test.scm
@@ -294,6 +294,17 @@
(test-equal "pushed above floor" 28 (entity-ref result #:y))
(test-equal "vy zeroed" 0 (entity-ref result #:vy))))))
+ (test-group "high-velocity fall: snaps to first solid row, not last"
+ ;; Regression: entity falls fast enough that apply-velocity-y moves it into TWO solid rows.
+ ;; Rows 2 and 3 are both solid (tileheight=16, so row 2 = y=[32,47], row 3 = y=[48,63]).
+ ;; After apply-velocity-y the entity lands at y=34 (overlapping both rows 2 and 3).
+ ;; Correct: snap to top of row 2 → y=16. Bug was: fold overwrote row 2 snap with row 3 snap → y=32 (inside row 2).
+ (let* ((tm (make-test-tilemap '((0 0 0) (0 0 0) (1 0 0) (1 0 0) (0 0 0))))
+ (e '(#:type player #:x 0 #:y 34 #:width 16 #:height 16 #:vx 0 #:vy 20)))
+ (let ((result (resolve-tile-collisions-y e tm)))
+ (test-equal "snapped to first solid row" 16 (entity-ref result #:y))
+ (test-equal "vy zeroed" 0 (entity-ref result #:vy)))))
+
;; Integration test: simulate the actual game physics loop
(test-group "multi-frame physics simulation"
(test-group "player falls and lands on floor (10 frames)"