aboutsummaryrefslogtreecommitdiff
path: root/bullets.lua
diff options
context:
space:
mode:
author1029chris <1029chris@gmail.com>2022-02-04 16:12:11 -0800
committer1029chris <1029chris@gmail.com>2022-02-04 16:12:11 -0800
commitf53f66987ade0b3f2811cacbdcf72c474170621e (patch)
treee540e63083db6258d61a18eedc29980cc692b34f /bullets.lua
parent39ecc01dba7141bce30292a38eca2f498919fb33 (diff)
Pickups! Camera Shake! sPARKS!! YEAHH!!!
Diffstat (limited to 'bullets.lua')
-rw-r--r--bullets.lua10
1 files changed, 8 insertions, 2 deletions
diff --git a/bullets.lua b/bullets.lua
index 820f3ef..ea82be7 100644
--- a/bullets.lua
+++ b/bullets.lua
@@ -3,7 +3,6 @@ bullets = {}
function addbullet(x, y, velx, vely, evil, sprite)
local bullet = {}
- bullet.type = "bullet"
bullet.sprite = sprite
bullet.evil = evil
bullet.x = x
@@ -22,6 +21,13 @@ function addbullet(x, y, velx, vely, evil, sprite)
end
end
+ function bullet.accurate_collide(object)
+ if bullet.x+4 >= object.x-2 and bullet.x+4 <= object.x+2+object.w and bullet.y+4 >= object.y-2 and bullet.y+4 <= object.y+object.h+2 and object.inv < 0 then
+ object:shot()
+ del(obj, bullet)
+ end
+ end
+
function bullet.update(bullet)
--applying velocity
bullet.x += bullet.velx
@@ -31,7 +37,7 @@ function addbullet(x, y, velx, vely, evil, sprite)
if bullet.evil then
foreach(players, bullet.collide)
elseif bullet.evil == false then
- foreach(enemies, bullet.collide)
+ foreach(enemies, bullet.accurate_collide)
end
--delete bullet if off screen