Mothback/code/entities/hook_anchor.lua

47 lines
822 B
Lua
Raw Permalink Normal View History

HookAnchor = Entity:New()
2022-02-15 09:21:24 +00:00
function HookAnchor:New(x,y,hookDistance)
2022-02-26 02:56:53 +00:00
local o = Entity:New(x,y)
2022-02-15 09:21:24 +00:00
2022-02-26 02:56:53 +00:00
o.type = "hook_anchor"
2022-02-15 09:21:24 +00:00
2022-02-26 02:56:53 +00:00
o.pos = {x = x, y = y}
o.hookDistance = hookDistance or 100
-- animations
o.body = Animation:New(animation.fairy.flying)
o:centerOffset(o.body)
o:getBoundingBox(o.body)
2022-02-15 09:21:24 +00:00
2022-02-26 02:56:53 +00:00
table.insert(LoadedObjects.Entities,o)
o.id = #LoadedObjects.Entities
2022-02-15 09:21:24 +00:00
2022-02-26 02:56:53 +00:00
setmetatable(o, self)
self.__index = self
return o
2022-02-15 09:21:24 +00:00
end
function HookAnchor:HandleAnimation()
2022-02-26 02:56:53 +00:00
self.body:Animate()
self:Draw(self.body)
end
function HookAnchor:DrawBackground()
2022-02-26 02:56:53 +00:00
Entity.DrawBackground(self)
love.graphics.setColor(1,1,1,0)
love.graphics.circle(
"fill",
-Camera.pos.x + self.pos.x,
-Camera.pos.y + self.pos.y,
self.hookDistance
)
2022-02-15 09:21:24 +00:00
end
function HookAnchor:DoPhysics()
end
2022-02-15 09:44:02 +00:00
function Fairy:Debug()
2022-02-26 02:56:53 +00:00
Entity.Debug(self)
2022-02-15 09:44:02 +00:00
end