 local Object = require "classic"
local Button = Object:extend()

function Button:new(x, y, r, b, c)
    self.x = x
    self.y = y
    self.r = r
    self.b = b
    self.press = false
    self.c = c
end

function Button:update(dt)
    if self.b == "triggerleft" or self.b == "triggerright" then
        if fightstick:getGamepadAxis(self.b) == 1 then
            self.press = true
        else
            self.press = false
        end
    else
    if fightstick:isGamepadDown(self.b) then
            self.press = true
        else
            self.press = false
        end
    end
end

function Button:draw()
    if self.press then
        love.graphics.setColor(self.c)
    else
        love.graphics.setColor(75/255, 75/255, 75/255)
    end
    
    love.graphics.circle("fill", self.x + self.r, self.y + self.r, self.r+1)
    love.graphics.setColor(1,1,1)
    love.graphics.circle("line", self.x + self.r, self.y+self.r, self.r+1)
end

return Button
