65 lines
1.6 KiB
Lua
65 lines
1.6 KiB
Lua
local StatusBar = Object:extend()
|
|
local TweenManager = require "birb.classes.time"
|
|
|
|
local gui = require "game.modules.gui"
|
|
|
|
local Emblem = require "game.modules.gui.emblem"
|
|
local ComplexHPBar = require "game.modules.gui.complexhpbar"
|
|
|
|
function StatusBar:new(abstract, scene)
|
|
self.assets = scene.assets
|
|
self.abstract = abstract
|
|
|
|
self.emblem = Emblem(abstract, scene)
|
|
|
|
self.hp = self.abstract.hp
|
|
self.pp = self.abstract.pp
|
|
self.stats = self.abstract:getStats()
|
|
|
|
self.hpbar = ComplexHPBar(58)
|
|
self.ppbar = ComplexHPBar(58)
|
|
self.hpbar:setColorForeground(248/255, 160/255, 0, 1)
|
|
self.hpbar:setColorBackground(112/255, 0, 0)
|
|
self.ppbar:setColorForeground(0, 248/255, 248/255, 1)
|
|
self.ppbar:setColorBackground(0, 54/255, 229/255)
|
|
|
|
self.tweens = TweenManager(self)
|
|
end
|
|
|
|
function StatusBar:update(dt)
|
|
self.tweens:update(dt)
|
|
end
|
|
|
|
function StatusBar:updateHP()
|
|
self.tweens:newTween(0, 0.3, {hp = self.abstract.hp}, 'linear')
|
|
end
|
|
|
|
function StatusBar:updatePP()
|
|
self.tweens:newTween(0, 0.3, {pp = self.abstract.pp}, 'linear')
|
|
end
|
|
|
|
function StatusBar:draw(x, y)
|
|
self.emblem:drawBackground(x, y)
|
|
self:drawStatusArea(x+10, y-8)
|
|
self.emblem:drawForeground(x, y)
|
|
end
|
|
|
|
function StatusBar:drawStatusArea(x, y)
|
|
self.assets.images["statusbar"]:draw(x, y)
|
|
|
|
local hpmax = self.stats:get(self.stats.HPMAX)
|
|
local ppmax = self.stats:get(self.stats.PPMAX)
|
|
|
|
self.assets.fonts["hudnbrs_small"]:set()
|
|
self.hpbar:drawWithLabels(x + 6, y + 9, self.hp, hpmax)
|
|
self.ppbar:drawWithLabels(x + 18, y + 21, self.pp, ppmax)
|
|
|
|
local lvl = self.abstract.level
|
|
|
|
if lvl < 100 then
|
|
lvl = "0" .. lvl
|
|
end
|
|
love.graphics.print(lvl, x+42, y+1)
|
|
end
|
|
|
|
return StatusBar
|