Bullet actor collisions

This commit is contained in:
MaddoScientisto 2024-04-28 17:06:07 +02:00
commit 0e0a458949
5 changed files with 92 additions and 18 deletions

View file

@ -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