sonic-radiance/sonic-radiance.love/scenes/battlesystem/gui/simplehpbar.lua

30 lines
695 B
Lua
Raw Normal View History

local SimpleHPBar = Object:extend()
local TweenManager = require "game.modules.tweenmanager"
local gui = require "game.modules.gui"
function SimpleHPBar:new(hp)
self.tweens = TweenManager(self)
self.hp = hp
self.baseHP = hp
end
function SimpleHPBar:setHP(newHP)
self.tweens:newTween(0, 0.1, {hp = newHP}, 'inCubic')
end
function SimpleHPBar:update(dt)
self.tweens:update(dt)
end
function SimpleHPBar:draw(x, y)
love.graphics.setColor(0, 0, 0, 1)
gui.drawBar(x, y, 26, 4)
love.graphics.setColor(248/255, 160/255, 0, 1)
local bar = math.floor(24 * (self.hp / self.baseHP))
gui.drawBar(x, y + 1, bar, 2)
love.graphics.setColor(1, 1, 1, 1)
end
return SimpleHPBar