chore: extract emblem from statusbar
This commit is contained in:
parent
955d8d33d9
commit
cfbe2f4b90
2 changed files with 27 additions and 17 deletions
22
sonic-radiance.love/game/modules/gui/emblem.lua
Normal file
22
sonic-radiance.love/game/modules/gui/emblem.lua
Normal 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
|
|
@ -3,18 +3,17 @@ local TweenManager = require "game.modules.tweenmanager"
|
|||
|
||||
local gui = require "game.modules.gui"
|
||||
|
||||
local HUDBASE = 8
|
||||
local HUDSEP = 152
|
||||
local Emblem = require "game.modules.gui.emblem"
|
||||
|
||||
function StatusBar:new(abstract, scene)
|
||||
self.assets = scene.assets
|
||||
self.abstract = abstract
|
||||
|
||||
self.charid = self.abstract.simplename
|
||||
self.stats = self.abstract:getStats()
|
||||
self.emblem = Emblem(abstract, scene)
|
||||
|
||||
self.hp = self.abstract.hp
|
||||
self.pp = self.abstract.pp
|
||||
self.stats = self.abstract:getStats()
|
||||
|
||||
self.tweens = TweenManager(self)
|
||||
end
|
||||
|
@ -31,19 +30,8 @@ function StatusBar:updatePP()
|
|||
self.tweens:newTween(0, 0.3, {pp = self.abstract.pp}, 'linear')
|
||||
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)
|
||||
self:drawEmblem(x, y)
|
||||
self.emblem:draw(x, y)
|
||||
self.assets.images["statusbar"]:draw(x+12, y-6)
|
||||
|
||||
local hpmax = self.stats.hpmax
|
||||
|
|
Loading…
Reference in a new issue