From 78a924defabc862a7cfa5476091152c1ef5333ee Mon Sep 17 00:00:00 2001 From: Gene Pasquet Date: Mon, 6 Apr 2026 03:41:09 +0100 Subject: Fixes, updated license --- tests/physics-test.scm | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'tests/physics-test.scm') 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)" -- cgit v1.2.3