diff options
| author | 1029chris <1029chris@gmail.com> | 2022-02-02 17:13:53 -0800 |
|---|---|---|
| committer | 1029chris <1029chris@gmail.com> | 2022-02-02 17:13:53 -0800 |
| commit | 23383a22b2b1e0508053f9559f4174d7e163b103 (patch) | |
| tree | f4666f7351bc8630bc00352cb9cbf7f188f3a3ee /bullets.lua | |
| parent | 6d84e60455afb5e45db773541ff4b96e91c06705 (diff) | |
Added circle particles, and more bullet stuff
Diffstat (limited to 'bullets.lua')
| -rw-r--r-- | bullets.lua | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/bullets.lua b/bullets.lua index dad5ba4..01e6dc7 100644 --- a/bullets.lua +++ b/bullets.lua @@ -4,6 +4,7 @@ function addbullet(x, y, velx, vely, evil) local bullet = {} bullet.type = "bullet" + bullet.evil = evil bullet.x = x bullet.y = y bullet.velx = velx @@ -13,9 +14,10 @@ function addbullet(x, y, velx, vely, evil) spr(6, bullet.x, bullet.y) end - function bullet.collide(object, bullet) - if bullet.x >= object.x and bullet.x <= object.x+object.w and bullet.y >= object.y and bullet.y <= object.y+object.h then - cls(4) + function bullet.collide(object) + if bullet.x+4 >= object.x and bullet.x+4 <= object.x+object.w and bullet.y+4 >= object.y and bullet.y+4 <= object.y+object.h and object.inv < 0 then + object:shot() + del(obj, bullet) end end @@ -26,7 +28,9 @@ function addbullet(x, y, velx, vely, evil) --collision detection if bullet.evil then - foreach(players, bullet.collide(bullet)) + foreach(players, bullet.collide) + elseif bullet.good then + --foreach(enemies, bullet.collide) end --delete bullet if off screen @@ -37,4 +41,6 @@ function addbullet(x, y, velx, vely, evil) add(obj, bullet) add(bullet, #obj) -end
\ No newline at end of file +end + +addbullet(120, 60, -1, 0, true)
\ No newline at end of file |
