sonic-radiance/sonic-radiance.love/game/modules/gui/bosshpbar.lua
2021-03-11 23:47:32 +01:00

30 lines
No EOL
791 B
Lua

local BossHpBar = Object:extend()
local TweenManager = require "game.modules.tweenmanager"
local ComplexHPBar = require "game.modules.gui.complexhpbar"
function BossHpBar:new(hp)
self.tweens = TweenManager(self)
self.hp = hp
self.baseHP = hp
self.hpbar = ComplexHPBar(120)
self.hpbar:setColorForeground(248/255, 160/255, 0, 1)
self.hpbar:setColorBackground(112/255, 0, 0)
self.bossTexture = love.graphics.newImage("assets/gui/strings/boss.png")
end
function BossHpBar:setHP(newHP)
self.tweens:newTween(0, 0.1, {hp = newHP}, 'inCubic')
end
function BossHpBar:update(dt)
self.tweens:update(dt)
end
function BossHpBar:draw(x, y)
self.hpbar:draw(x, y, self.hp / self.baseHP)
love.graphics.draw(self.bossTexture, x + 98, y + 10)
end
return BossHpBar