Proper actors implementation

This commit is contained in:
MaddoScientisto 2024-04-26 11:22:51 +02:00
commit 6a7e938a39
5 changed files with 88 additions and 68 deletions

View file

@ -1,24 +1,27 @@
--M = {}
actor = {}
actor.__index = actor
function actor:new(x,y)
local o = setmetatable({}, actor)
o.x=x
o.y=y
o.life=100
o.spriteIndex=0
return o
Actor = {
life=100,
spriteIndex=0,
}
--actor.__index = actor
function Actor:new(new_x,new_y)
local o = {
x=new_x,
y=new_y,
}
return setmetatable(o, {__index=self})
end
function actor:update()
function Actor:update()
end
function actor:draw()
function Actor:draw()
spr(self.spriteIndex,self.x,self.y)
end
--M.actor = actor
return actor
return Actor