bytepath/obj/game/Circle.lua
2025-11-10 02:52:20 -03:00

36 lines
1.2 KiB
Lua

---@class Circle:GameObject circle object
---@field area Area area of circle
---@field x number horizontal position of circle
---@field y number vertical position of circle
---@field radius number radius of circle
---@field mode string drawing mode of circle
local Circle = GameObject:extend()
function Circle:new(area, x, y, config)
Circle.super.new(self, area, x or 400, y or 300)
self.tweened = false
self.current_radius = 0
self.radius = config.radius or 50
self.mode = config.mode or "fill"
self._r, self._g, self._b = love.math.random(0.1, 1.0), love.math.random(0.1, 1.0), love.math.random(0.1, 1.0)
end
function Circle:update(dt)
Circle.super.update(self, dt)
if not self.tweened then
self.tweened = true
self.timer:tween(0.4, self, {current_radius = self.radius}, 'in-out-cubic')
end
end
function Circle:draw()
Circle.super.draw(self)
love.graphics.setColor(self._r, self._g, self._b)
love.graphics.circle(self.mode, self.x, self.y, self.current_radius)
end
function Circle:kill()
self.timer:tween(0.4, self, {current_radius = 0}, 'in-out-cubic', function() self:destroy() end)
end
return Circle