summary refs log tree commit diff
path: root/lib/player.fnl
diff options
context:
space:
mode:
authorequa <equaa@protonmail.com>2021-04-22 22:18:58 -0500
committerequa <equaa@protonmail.com>2021-04-22 22:18:58 -0500
commit5473d5d303b55b06438d65c4b3abd2fc0b0f86fc (patch)
treedea5e968dd6097b30c7f78ce10a628a2cfa83dfd /lib/player.fnl
parentd699b9a38da59bc32982db0c8a69c02cd595cdbc (diff)
very messy music
Diffstat (limited to 'lib/player.fnl')
-rw-r--r--lib/player.fnl4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/player.fnl b/lib/player.fnl
index 4693d2e..d40e980 100644
--- a/lib/player.fnl
+++ b/lib/player.fnl
@@ -3,6 +3,7 @@
 (local cell (require :lib.cell))
 (local cells (require :lib.cells))
 (local bullet (require :lib.bullet))
+(local music-state (require :lib.music-state))
 
 (fn init [self pos]
   (setmetatable {entity.position pos
@@ -15,6 +16,7 @@
 (fn steer [self game id controls]
   (when (> self.shot-age 0)
     (set self.shot-age (- self.shot-age 1)))
+  (set music-state.shot-age self.shot-age)
   ;; TODO: smooth turning
   (when controls.left
     (set self.target-spin (- self.target-spin 0.15)))
@@ -23,12 +25,14 @@
     (set self.target-spin (+ self.target-spin 0.15)))
   (set self.direction (% (+ self.direction (* self.target-spin 0.1)) (* math.pi 2)))
   (set self.target-spin (* self.target-spin 0.9))
+  (set music-state.forward controls.up)
   (when controls.up
     (local v (entity.velocity self))
     (set v.x (+ v.x (* (math.cos self.direction) 0.02)))
     (set v.y (+ v.y (* (math.sin self.direction) 0.02)))
     (when (> (vec.mag v) 0.8)
       (tset self entity.velocity (vec.mul v (/ 0.8 (vec.mag v))))))
+  (set music-state.speed (vec.mag (. self entity.velocity)))
   (when (and controls.shoot (= self.shot-age 0))
     (set self.shot-age 10)
     (local v (entity.velocity self))