sonic-radiance/sonic-radiance.love/game/modules/gui/bosshpbar.lua

30 lines
783 B
Lua
Raw Normal View History

2021-03-11 23:47:32 +01:00
local BossHpBar = Object:extend()
local TweenManager = require "birb.classes.time"
2021-03-11 23:47:32 +01:00
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