2020-05-01 17:04:17 +02:00
|
|
|
local StatusBar = Object:extend()
|
2021-05-05 11:41:25 +02:00
|
|
|
local TweenManager = require "birb.classes.time"
|
2020-05-01 17:04:17 +02:00
|
|
|
|
2020-08-03 09:34:23 +02:00
|
|
|
local gui = require "game.modules.gui"
|
2020-05-01 17:04:17 +02:00
|
|
|
|
2020-08-03 09:34:23 +02:00
|
|
|
local Emblem = require "game.modules.gui.emblem"
|
2020-10-04 09:26:49 +02:00
|
|
|
local ComplexHPBar = require "game.modules.gui.complexhpbar"
|
2020-05-01 17:04:17 +02:00
|
|
|
|
2020-08-03 09:24:52 +02:00
|
|
|
function StatusBar:new(abstract, scene)
|
|
|
|
self.assets = scene.assets
|
|
|
|
self.abstract = abstract
|
2020-05-01 17:04:17 +02:00
|
|
|
|
2020-08-03 09:34:23 +02:00
|
|
|
self.emblem = Emblem(abstract, scene)
|
2020-05-01 17:04:17 +02:00
|
|
|
|
2020-07-19 16:20:57 +02:00
|
|
|
self.hp = self.abstract.hp
|
|
|
|
self.pp = self.abstract.pp
|
2020-08-03 09:34:23 +02:00
|
|
|
self.stats = self.abstract:getStats()
|
2020-05-01 17:04:17 +02:00
|
|
|
|
2020-10-04 09:26:49 +02:00
|
|
|
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)
|
|
|
|
|
2020-05-01 17:04:17 +02:00
|
|
|
self.tweens = TweenManager(self)
|
|
|
|
end
|
|
|
|
|
|
|
|
function StatusBar:update(dt)
|
|
|
|
self.tweens:update(dt)
|
|
|
|
end
|
|
|
|
|
|
|
|
function StatusBar:updateHP()
|
2020-07-24 19:49:24 +02:00
|
|
|
self.tweens:newTween(0, 0.3, {hp = self.abstract.hp}, 'linear')
|
2020-05-01 17:04:17 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
function StatusBar:updatePP()
|
2020-07-24 19:49:24 +02:00
|
|
|
self.tweens:newTween(0, 0.3, {pp = self.abstract.pp}, 'linear')
|
2020-05-01 17:04:17 +02:00
|
|
|
end
|
|
|
|
|
2020-08-03 09:24:52 +02:00
|
|
|
function StatusBar:draw(x, y)
|
2020-08-04 19:53:11 +02:00
|
|
|
self.emblem:drawBackground(x, y)
|
|
|
|
self:drawStatusArea(x+10, y-8)
|
|
|
|
self.emblem:drawForeground(x, y)
|
|
|
|
end
|
2020-05-01 17:04:17 +02:00
|
|
|
|
2020-08-04 19:53:11 +02:00
|
|
|
function StatusBar:drawStatusArea(x, y)
|
|
|
|
self.assets.images["statusbar"]:draw(x, y)
|
2020-05-01 17:04:17 +02:00
|
|
|
|
2020-08-04 19:53:11 +02:00
|
|
|
local hpmax = self.stats.hpmax
|
|
|
|
local ppmax = self.stats.ppmax
|
2020-05-01 17:04:17 +02:00
|
|
|
|
2020-08-04 19:53:11 +02:00
|
|
|
self.assets.fonts["hudnbrs_small"]:set()
|
2020-10-04 09:26:49 +02:00
|
|
|
self.hpbar:drawWithLabels(x + 6, y + 9, self.hp, hpmax)
|
|
|
|
self.ppbar:drawWithLabels(x + 18, y + 21, self.pp, ppmax)
|
2020-05-01 17:04:17 +02:00
|
|
|
|
2020-08-04 19:53:11 +02:00
|
|
|
local lvl = self.abstract.level
|
2020-05-01 17:04:17 +02:00
|
|
|
|
2020-08-04 19:53:11 +02:00
|
|
|
if lvl < 100 then
|
|
|
|
lvl = "0" .. lvl
|
|
|
|
end
|
|
|
|
love.graphics.print(lvl, x+42, y+1)
|
2020-05-01 17:04:17 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
return StatusBar
|