2020-05-01 17:04:17 +02:00
|
|
|
local StatusBar = Object:extend()
|
|
|
|
local TweenManager = require "game.modules.tweenmanager"
|
|
|
|
|
|
|
|
local gui = require "game.modules.gui"
|
|
|
|
|
|
|
|
local HUDBASE = 8
|
|
|
|
local HUDSEP = 152
|
|
|
|
|
2020-07-19 16:20:57 +02:00
|
|
|
function StatusBar:new(fighter)
|
|
|
|
self.fighter = fighter
|
|
|
|
self.hud = fighter.turnSystem.hud
|
|
|
|
self.assets = self.fighter.assets
|
2020-05-01 17:04:17 +02:00
|
|
|
|
2020-07-19 16:20:57 +02:00
|
|
|
self.charid = self.fighter.name
|
|
|
|
self.stats = self.fighter:getStats()
|
|
|
|
self.abstract = self.fighter.abstract
|
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-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
|
|
|
|
|
|
|
|
function StatusBar:drawEmblem(x, y)
|
|
|
|
self.assets.images["e_speedster"]:draw(x, y)
|
|
|
|
core.screen:setScissor(x, y-16, 32, 40)
|
|
|
|
self.assets.sprites[self.charid]:drawAnimation(x+14, y+14)
|
|
|
|
core.screen:resetScissor( )
|
|
|
|
self.assets.images["m_speedster"]:draw(x, y)
|
|
|
|
end
|
|
|
|
|
|
|
|
function StatusBar:draw()
|
2020-07-19 16:20:57 +02:00
|
|
|
local x = HUDBASE + (self.fighter.id-1)*HUDSEP
|
|
|
|
local y = self.hud:getPlayerHUDPosition()
|
2020-05-01 17:04:17 +02:00
|
|
|
|
|
|
|
self:drawEmblem(x, y)
|
|
|
|
self.assets.images["statusbar"]:draw(x+12, y-6)
|
|
|
|
|
|
|
|
local hpmax = self.stats.hpmax
|
|
|
|
local ppmax = self.stats.ppmax
|
|
|
|
|
|
|
|
local bar1 = math.floor((self.hp/self.stats.hpmax)*107)
|
|
|
|
local bar2 = math.floor((self.pp/self.stats.ppmax)*108)
|
|
|
|
|
|
|
|
love.graphics.setColor(248/255, 160/255, 0, 1)
|
|
|
|
gui.drawBar(x+29, y+5, bar1, 7)
|
|
|
|
love.graphics.setColor(0, 248/255, 248/255, 1)
|
|
|
|
gui.drawBar(x+17, y+17, bar2, 7)
|
|
|
|
utils.graphics.resetColor()
|
|
|
|
|
|
|
|
self.assets.fonts["hudnbrs_small"]:set()
|
|
|
|
love.graphics.print(math.floor(self.hp) .. "/" .. hpmax, x+34, y+5)
|
|
|
|
love.graphics.print(math.floor(self.pp) .. "/" .. ppmax, x+28, y+17)
|
|
|
|
|
2020-07-19 16:20:57 +02:00
|
|
|
local lvl = self.abstract.level
|
2020-05-01 17:04:17 +02:00
|
|
|
|
|
|
|
if lvl < 100 then
|
|
|
|
lvl = "0" .. lvl
|
|
|
|
end
|
|
|
|
|
|
|
|
love.graphics.print(lvl, x+122, y-5)
|
|
|
|
end
|
|
|
|
|
|
|
|
return StatusBar
|