summary refs log tree commit diff
diff options
context:
space:
mode:
authorequa <equaa@protonmail.com>2021-04-20 23:35:51 -0500
committerequa <equaa@protonmail.com>2021-04-20 23:35:51 -0500
commitac0c1a1a6289998ed6f18a1f01772053d0b28d30 (patch)
tree029efec3e5d6a4d5fd6ca4e0c98a4ceb54675b4e
parent5c4b1aba561c206744b3354478069677b3947e67 (diff)
fix wrapping maybe
-rw-r--r--lib/game.fnl13
1 files 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))