From ac0c1a1a6289998ed6f18a1f01772053d0b28d30 Mon Sep 17 00:00:00 2001 From: equa Date: Tue, 20 Apr 2021 23:35:51 -0500 Subject: fix wrapping maybe --- lib/game.fnl | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/game.fnl b/lib/game.fnl index a0218b3..d07f58c 100644 --- a/lib/game.fnl +++ b/lib/game.fnl @@ -117,6 +117,13 @@ :y (* height (- 1 (/ clipped-y radius-y)) 0.5)} display-b {:x (- width display-a.x) :y (- height display-a.y)} display-size (vec.sub display-b display-a) + ;; these are used to "wrap around" various entities so that they + ;; always render in their proper position relative to the ship, even + ;; over random edges. feels a bit hacky though + camera-a-full {:x (- ship-pos.x (/ self.width 2)) + :y (- ship-pos.y (/ self.height 2))} + camera-b-full {:x (+ ship-pos.x (/ self.width 2)) + :y (+ ship-pos.y (/ self.height 2))} camera-a {:x (- ship-pos.x clipped-x) :y (- ship-pos.y clipped-y)} camera-b {:x (+ ship-pos.x clipped-x) @@ -164,9 +171,9 @@ (love.graphics.push) (let [pos (entity.position v) render-pos (vec.lerp camera-a camera-b display-a display-b - (vec.add camera-a - (vec.wrap (vec.sub pos camera-a) - (vec.sub camera-b camera-a))))] + (vec.add camera-a-full + (vec.wrap (vec.sub pos camera-a-full) + (vec.sub camera-b-full camera-a-full))))] (love.graphics.translate render-pos.x render-pos.y) (love.graphics.scale cell-box.x cell-box.y)) -- cgit 1.3.0-6-gf8a5