summary refs log tree commit diff
path: root/lib/bullet.fnl
diff options
context:
space:
mode:
Diffstat (limited to 'lib/bullet.fnl')
-rw-r--r--lib/bullet.fnl11
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/bullet.fnl b/lib/bullet.fnl
index d7f1b62..0fe1737 100644
--- a/lib/bullet.fnl
+++ b/lib/bullet.fnl
@@ -3,18 +3,19 @@
 (local cell (require :lib.cell))
 (local cells (require :lib.cells))
 
-(fn init [self pos vel]
+(fn init [self pos vel dir]
   (setmetatable {entity.position pos
                  entity.velocity vel
-                 entity.duration 120}
+                 entity.duration 120
+                 :direction dir}
                 self))
 
 (fn draw [self game id]
   (love.graphics.setColor 1 1 1 (/ (entity.duration self) 120))
-  (love.graphics.setLineWidth 0.3)
+  (love.graphics.setLineWidth 0.2)
   (love.graphics.line 0 0
-                      (. self entity.velocity :x)
-                      (. self entity.velocity :y)))
+                      (* (math.cos self.direction) (vec.mag (. self entity.velocity)))
+                      (* (math.sin self.direction) (vec.mag (. self entity.velocity)))))
 
 (fn collide [self game id x y]
   (when (> (cell.aliveness (. game.grid x y)) 0)