diff options
author | equa <equaa@protonmail.com> | 2021-04-22 14:23:39 -0500 |
---|---|---|
committer | equa <equaa@protonmail.com> | 2021-04-22 14:23:39 -0500 |
commit | d699b9a38da59bc32982db0c8a69c02cd595cdbc (patch) | |
tree | 37eba087eee569be5dca97bad25f29213df1f22b /lib/bullet.fnl | |
parent | 3c98f936af7754e9deb4912e54ec12a3df9b5938 (diff) |
better? bullet rendering
Diffstat (limited to 'lib/bullet.fnl')
-rw-r--r-- | lib/bullet.fnl | 11 |
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) |