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 --- physics.scm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'physics.scm') diff --git a/physics.scm b/physics.scm index 06cb12c..627dbea 100644 --- a/physics.scm +++ b/physics.scm @@ -90,6 +90,8 @@ ;; Resolve collisions with tiles along a single axis. ;; push-fn: (v col row) -> new-pos + ;; For v>0 (moving right/down): snap to the FIRST solid cell (shallowest penetration). + ;; For v<0 (moving left/up): snap to the LAST solid cell (deepest penetration from above/left). (define (resolve-tile-collisions-axis entity tilemap vel-key pos-key push-fn) (let ((v (entity-ref entity vel-key 0))) (if (zero? v) @@ -101,7 +103,9 @@ (tile-id (tilemap-tile-at tilemap col row))) (if (zero? tile-id) acc - (entity-set (entity-set acc pos-key (push-fn v col row)) vel-key 0)))) + (if (and (> v 0) (zero? (entity-ref acc vel-key v))) + acc ; v>0: first collision already resolved, don't overwrite + (entity-set (entity-set acc pos-key (push-fn v col row)) vel-key 0))))) entity (entity-tile-cells entity tilemap))))) -- cgit v1.2.3