From 5473d5d303b55b06438d65c4b3abd2fc0b0f86fc Mon Sep 17 00:00:00 2001 From: equa Date: Thu, 22 Apr 2021 22:18:58 -0500 Subject: very messy music --- lib/player.fnl | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'lib/player.fnl') 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)) -- cgit 1.3.0-6-gf8a5