diff options
| author | Gene Pasquet <dev@etenil.net> | 2026-04-06 03:41:09 +0100 |
|---|---|---|
| committer | Gene Pasquet <dev@etenil.net> | 2026-04-06 03:41:09 +0100 |
| commit | 78a924defabc862a7cfa5476091152c1ef5333ee (patch) | |
| tree | 5e7e13ca27848dfe87ecf3eb82689d8e9488beb3 /physics.scm | |
| parent | c4ebbbdd1a0bd081a2ed9447ba8188d97ae54717 (diff) | |
Fixes, updated license
Diffstat (limited to 'physics.scm')
| -rw-r--r-- | physics.scm | 6 |
1 files changed, 5 insertions, 1 deletions
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))))) |
