chore: extract emblem from statusbar

This commit is contained in:
Kazhnuz 2020-08-03 09:34:23 +02:00
parent 955d8d33d9
commit cfbe2f4b90
2 changed files with 27 additions and 17 deletions

View file

@ -0,0 +1,22 @@
local Emblem = Object:extend()
function Emblem:new(abstract, scene)
self.assets = scene.assets
self.abstract = abstract
self.charid = self.abstract.simplename
self.stats = self.abstract:getStats()
end
function Emblem:draw(x, y)
local emblem1 = "e_" .. self.abstract.data.class
local emblem2 = "m_" .. self.abstract.data.class
self.assets.images[emblem1]: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[emblem2]:draw(x, y)
end
return Emblem

View file

@ -1,20 +1,19 @@
local StatusBar = Object:extend() local StatusBar = Object:extend()
local TweenManager = require "game.modules.tweenmanager" local TweenManager = require "game.modules.tweenmanager"
local gui = require "game.modules.gui" local gui = require "game.modules.gui"
local HUDBASE = 8 local Emblem = require "game.modules.gui.emblem"
local HUDSEP = 152
function StatusBar:new(abstract, scene) function StatusBar:new(abstract, scene)
self.assets = scene.assets self.assets = scene.assets
self.abstract = abstract self.abstract = abstract
self.charid = self.abstract.simplename self.emblem = Emblem(abstract, scene)
self.stats = self.abstract:getStats()
self.hp = self.abstract.hp self.hp = self.abstract.hp
self.pp = self.abstract.pp self.pp = self.abstract.pp
self.stats = self.abstract:getStats()
self.tweens = TweenManager(self) self.tweens = TweenManager(self)
end end
@ -31,19 +30,8 @@ function StatusBar:updatePP()
self.tweens:newTween(0, 0.3, {pp = self.abstract.pp}, 'linear') self.tweens:newTween(0, 0.3, {pp = self.abstract.pp}, 'linear')
end end
function StatusBar:drawEmblem(x, y)
local emblem1 = "e_" .. self.abstract.data.class
local emblem2 = "m_" .. self.abstract.data.class
self.assets.images[emblem1]: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[emblem2]:draw(x, y)
end
function StatusBar:draw(x, y) function StatusBar:draw(x, y)
self:drawEmblem(x, y) self.emblem:draw(x, y)
self.assets.images["statusbar"]:draw(x+12, y-6) self.assets.images["statusbar"]:draw(x+12, y-6)
local hpmax = self.stats.hpmax local hpmax = self.stats.hpmax