summary refs log tree commit diff
diff options
context:
space:
mode:
-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))