diff options
author | equa <equaa@protonmail.com> | 2021-04-19 20:39:21 -0500 |
---|---|---|
committer | equa <equaa@protonmail.com> | 2021-04-19 20:39:21 -0500 |
commit | 00af64d4e503dd82abf4657ec6fd44b0a418adb2 (patch) | |
tree | 4e864337769f5ddd792db95be3bc761159748af4 /lib/bullet.fnl | |
parent | ca870dab91daee38b8d55ac6d2f2b4fd6959c6ac (diff) |
cool bullets
Diffstat (limited to 'lib/bullet.fnl')
-rw-r--r-- | lib/bullet.fnl | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/bullet.fnl b/lib/bullet.fnl new file mode 100644 index 0000000..d7f1b62 --- /dev/null +++ b/lib/bullet.fnl @@ -0,0 +1,25 @@ +(local entity (require :lib.entity)) +(local vec (require :lib.vec)) +(local cell (require :lib.cell)) +(local cells (require :lib.cells)) + +(fn init [self pos vel] + (setmetatable {entity.position pos + entity.velocity vel + entity.duration 120} + self)) + +(fn draw [self game id] + (love.graphics.setColor 1 1 1 (/ (entity.duration self) 120)) + (love.graphics.setLineWidth 0.3) + (love.graphics.line 0 0 + (. self entity.velocity :x) + (. self entity.velocity :y))) + +(fn collide [self game id x y] + (when (> (cell.aliveness (. game.grid x y)) 0) + (tset game.entities id nil) + ;; TODO: less boom-y thing? + (tset game.grid x y (cell.init cells.boom (/ (entity.duration self) 180))))) + +{entity.init init entity.draw draw entity.collide collide} |