aboutsummaryrefslogtreecommitdiff
path: root/bullets.lua
diff options
context:
space:
mode:
author1029chris <1029chris@gmail.com>2022-02-02 14:34:05 -0800
committer1029chris <1029chris@gmail.com>2022-02-02 14:34:05 -0800
commit2c30b81ec818341251929d11c59e77cfefc5c3e3 (patch)
tree83c4159edd3072e904572c432a305818fdfcc559 /bullets.lua
parent29d9e7517dd77038df6f29f17e139b7ef68837ff (diff)
Added player controller and real basic bullets
Diffstat (limited to 'bullets.lua')
-rw-r--r--bullets.lua26
1 files changed, 26 insertions, 0 deletions
diff --git a/bullets.lua b/bullets.lua
new file mode 100644
index 0000000..b7b113d
--- /dev/null
+++ b/bullets.lua
@@ -0,0 +1,26 @@
+bullets = {}
+
+function addbullet(x, y, velx, vely, evil)
+ local bullet = {}
+
+ bullet.type = "bullet"
+ bullet.x = x
+ bullet.y = y
+ bullet.velx = velx
+ bullet.vely = vely
+
+ function bullet.draw(bullet)
+ spr(6, bullet.x, bullet.y)
+ end
+
+ function bullet.update(bullet)
+ bullet.x += bullet.velx
+ bullet.y += bullet.vely
+ if bullet.y > 128 or bullet.y < -8 or bullet.x > 128 or bullet.x < -8 then
+ del(obj, bullet)
+ end
+ end
+
+ add(obj, bullet)
+ add(bullet, #obj)
+end \ No newline at end of file