From d699b9a38da59bc32982db0c8a69c02cd595cdbc Mon Sep 17 00:00:00 2001 From: equa Date: Thu, 22 Apr 2021 14:23:39 -0500 Subject: better? bullet rendering --- lib/bullet.fnl | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'lib/bullet.fnl') 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) -- cgit 1.3.0-6-gf8a5