- More cleanup

- Added kupos entity and sprites (body, bow)
- Finally understood my code
This commit is contained in:
lustlion
2021-10-22 18:23:05 +02:00
parent 966aebf046
commit 5b7924fe4e
157 changed files with 394 additions and 1159 deletions

View File

@@ -0,0 +1,35 @@
Kupo = Entity:New(x,y)
function Kupo:New(x,y)
local o = Entity:New(x,y)
o.pos = {x = x, y = y}
o.speed = 20
o.range = 1000
setmetatable(o, self)
self.__index = self
return o
end
function Kupo:DoInput()
end
function Kupo:HandleAnimation()
-- flip sprite to look in the direction is moving
if self.vel.x ~= 0 then self.flip.x = math.sign(self.vel.x) end
self:LoadAnimation(animation.kupo.body)
end
function Kupo:DoPhysics()
-- horizontal collisions
if not isThereAnyCollisionAt(self.pos.x + self.vel.x, self.pos.y) then
self.pos.x = self.pos.x + self.vel.x
end
if not isThereAnyCollisionAt(self.pos.x, self.pos.y + self.vel.y) then
self.pos.y = self.pos.y + self.vel.y
end
end