From 2c30b81ec818341251929d11c59e77cfefc5c3e3 Mon Sep 17 00:00:00 2001 From: 1029chris <1029chris@gmail.com> Date: Wed, 2 Feb 2022 14:34:05 -0800 Subject: Added player controller and real basic bullets --- bullets.lua | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 bullets.lua (limited to 'bullets.lua') 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 -- cgit