diff --git a/sonic-radiance.love/game/modules/subgames/hud.lua b/sonic-radiance.love/game/modules/subgames/hud.lua index ce9f9c3..d986430 100644 --- a/sonic-radiance.love/game/modules/subgames/hud.lua +++ b/sonic-radiance.love/game/modules/subgames/hud.lua @@ -6,6 +6,7 @@ local Counter = require "birb.modules.gui.elements.counter" local Asset = require "birb.modules.gui.elements.assets" local Emblems = require "scenes.overworld.gui.hudelements.emblems" +local StatusBar = require "scenes.battlesystem.gui.hudelements.statutbar" local show = { -- {"rings", "movement", 0, 0.3, 16, 16, "inOutQuart"}, @@ -52,6 +53,7 @@ function OWScreen:createElements() -- }), 0, -100}, -- {TimeElement("hudnbrs", 408, 250, "right"), 0, -100}, Emblems(500, 24), + StatusBar(), -- Lifebars(-124, 168), -- Interactions() } diff --git a/sonic-radiance.love/scenes/battlesystem/gui/hudelements/statutbar.lua b/sonic-radiance.love/scenes/battlesystem/gui/hudelements/statutbar.lua index 2754ebe..0fac00b 100644 --- a/sonic-radiance.love/scenes/battlesystem/gui/hudelements/statutbar.lua +++ b/sonic-radiance.love/scenes/battlesystem/gui/hudelements/statutbar.lua @@ -7,16 +7,37 @@ local ComplexHPBar = require "game.modules.gui.complexhpbar" local DIST_STATUSBAR = 106 local Y = 200 -local STATUSBAR_W = 90 +local STATUSBAR_W = 128 +local HPBAR_W = STATUSBAR_W - 32 -function StatusBar:new(fighter, i) +function StatusBar:new(fighter, i, y) self:initAbstract(fighter) - StatusBar.super.new(self, self.abstract.name .. "StatutBar", (i-0.5)*DIST_STATUSBAR-(STATUSBAR_W/2), Y, STATUSBAR_W, 64) + local x = 16 + local y = 16 + if (i == 0) then + x = (i-0.5)*DIST_STATUSBAR-(STATUSBAR_W/2) + y = Y + end + + StatusBar.super.new(self, self.abstract.name .. "StatutBar", x, y, STATUSBAR_W, 64) self:createParts(self.scene) end +function StatusBar:update(dt) + StatusBar.super.update(self, dt) + if (self.currentChar ~= nil and self.currentChar ~= game.characters:getActiveCharacter()) then + self:initAbstract() + self:createParts(self.scene) + end +end + function StatusBar:initAbstract(fighter) - self.abstract = fighter.abstract + if (fighter == nil) then + self.currentChar = game.characters:getActiveCharacter() + self.abstract = game.characters:getActiveCharacterData() + else + self.abstract = fighter.abstract + end self.hp = self.abstract.hp self.pp = self.abstract.pp self.stats = self.abstract:getStats() @@ -25,8 +46,8 @@ end function StatusBar:createParts(scene) self.emblem = Emblem(self.abstract, scene) - self.hpbar = ComplexHPBar(58) - self.ppbar = ComplexHPBar(58) + self.hpbar = ComplexHPBar(HPBAR_W) + self.ppbar = ComplexHPBar(HPBAR_W) 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)