mirror of
https://gitlab.com/MaddoScientisto/cirnofarm.git
synced 2026-06-05 13:15:55 +00:00
Bullet actor collisions
This commit is contained in:
parent
f784bf43e9
commit
0e0a458949
5 changed files with 92 additions and 18 deletions
|
|
@ -1,16 +1,16 @@
|
|||
--M = {}
|
||||
|
||||
Actor = {
|
||||
life=100,
|
||||
spriteIndex=0,
|
||||
}
|
||||
Actor = {}
|
||||
--actor.__index = actor
|
||||
function Actor:new(new_x,new_y)
|
||||
local o = {
|
||||
x=new_x,
|
||||
y=new_y,
|
||||
w=16,
|
||||
h=16
|
||||
h=16,
|
||||
life=100,
|
||||
shootable=false
|
||||
--spriteIndex=0
|
||||
}
|
||||
|
||||
return setmetatable(o, {__index=self})
|
||||
|
|
@ -20,6 +20,17 @@ function Actor:update()
|
|||
|
||||
end
|
||||
|
||||
function Actor:destroy()
|
||||
|
||||
end
|
||||
|
||||
function Actor:damage(amount)
|
||||
self.life -= amount
|
||||
if (self.life <= 0) then
|
||||
self:destroy()
|
||||
end
|
||||
end
|
||||
|
||||
function Actor:draw()
|
||||
spr(self.spriteIndex,self.x,self.y)
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue