From cfbe2f4b90abd755ae030b534a39d71a4dd2d2cf Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Mon, 3 Aug 2020 09:34:23 +0200 Subject: [PATCH] chore: extract emblem from statusbar --- .../game/modules/gui/emblem.lua | 22 +++++++++++++++++++ .../game/modules/gui/statusbar.lua | 22 +++++-------------- 2 files changed, 27 insertions(+), 17 deletions(-) create mode 100644 sonic-radiance.love/game/modules/gui/emblem.lua diff --git a/sonic-radiance.love/game/modules/gui/emblem.lua b/sonic-radiance.love/game/modules/gui/emblem.lua new file mode 100644 index 0000000..094a65e --- /dev/null +++ b/sonic-radiance.love/game/modules/gui/emblem.lua @@ -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 diff --git a/sonic-radiance.love/game/modules/gui/statusbar.lua b/sonic-radiance.love/game/modules/gui/statusbar.lua index 1ef4f5f..78679be 100644 --- a/sonic-radiance.love/game/modules/gui/statusbar.lua +++ b/sonic-radiance.love/game/modules/gui/statusbar.lua @@ -1,20 +1,19 @@ local StatusBar = Object:extend() local TweenManager = require "game.modules.tweenmanager" -local gui = require "game.modules.gui" +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