diff --git a/sonic-radiance.love/assets/gui/crown.png b/sonic-radiance.love/assets/gui/crown.png new file mode 100644 index 0000000..8371f00 Binary files /dev/null and b/sonic-radiance.love/assets/gui/crown.png differ diff --git a/sonic-radiance.love/assets/gui/hpbar_boss.png b/sonic-radiance.love/assets/gui/hpbar_boss.png new file mode 100644 index 0000000..6686087 Binary files /dev/null and b/sonic-radiance.love/assets/gui/hpbar_boss.png differ diff --git a/sonic-radiance.love/assets/gui/strings/boss.png b/sonic-radiance.love/assets/gui/strings/boss.png new file mode 100644 index 0000000..9ff15a4 Binary files /dev/null and b/sonic-radiance.love/assets/gui/strings/boss.png differ diff --git a/sonic-radiance.love/game/modules/gui/bosshpbar.lua b/sonic-radiance.love/game/modules/gui/bosshpbar.lua new file mode 100644 index 0000000..c00c2e5 --- /dev/null +++ b/sonic-radiance.love/game/modules/gui/bosshpbar.lua @@ -0,0 +1,30 @@ +local BossHpBar = Object:extend() + +local TweenManager = require "game.modules.tweenmanager" +local ComplexHPBar = require "game.modules.gui.complexhpbar" + +function BossHpBar:new(hp) + self.tweens = TweenManager(self) + self.hp = hp + self.baseHP = hp + self.hpbar = ComplexHPBar(120) + self.hpbar:setColorForeground(248/255, 160/255, 0, 1) + self.hpbar:setColorBackground(112/255, 0, 0) + + self.bossTexture = love.graphics.newImage("assets/gui/strings/boss.png") +end + +function BossHpBar:setHP(newHP) + self.tweens:newTween(0, 0.1, {hp = newHP}, 'inCubic') +end + +function BossHpBar:update(dt) + self.tweens:update(dt) +end + +function BossHpBar:draw(x, y) + self.hpbar:draw(x, y, self.hp / self.baseHP) + love.graphics.draw(self.bossTexture, x + 98, y + 10) +end + +return BossHpBar \ No newline at end of file diff --git a/sonic-radiance.love/scenes/battlesystem/actors/ennemy.lua b/sonic-radiance.love/scenes/battlesystem/actors/ennemy.lua index f75a9eb..63cbfc2 100644 --- a/sonic-radiance.love/scenes/battlesystem/actors/ennemy.lua +++ b/sonic-radiance.love/scenes/battlesystem/actors/ennemy.lua @@ -22,7 +22,7 @@ function Ennemy:draw() self:drawSprite(0, -self.z) local x, y = self.world.map:gridToPixel(self.x, self.y, true) - self.owner:drawHUD(x - 12, y - self.owner.abstract.data.hudHeight - self.z) + self.owner:drawOversprite(x - 12, y - (self.owner.abstract.data.hudHeight * self.sprite.sy) - self.z) if (self.isSelected) then local height = 32 diff --git a/sonic-radiance.love/scenes/battlesystem/assets.lua b/sonic-radiance.love/scenes/battlesystem/assets.lua index 7191589..5425526 100644 --- a/sonic-radiance.love/scenes/battlesystem/assets.lua +++ b/sonic-radiance.love/scenes/battlesystem/assets.lua @@ -37,6 +37,7 @@ return { {"game", "assets/gui/strings/game.png"}, {"over", "assets/gui/strings/over.png"}, {"arrow", "assets/gui/arrow.png"}, + {"crown", "assets/gui/crown.png"} }, ["fonts"] = { {"small", "assets/gui/fonts/PixelOperator.ttf", 16}, diff --git a/sonic-radiance.love/scenes/battlesystem/controllers/ennemy.lua b/sonic-radiance.love/scenes/battlesystem/controllers/ennemy.lua index bf3724a..d9a2652 100644 --- a/sonic-radiance.love/scenes/battlesystem/controllers/ennemy.lua +++ b/sonic-radiance.love/scenes/battlesystem/controllers/ennemy.lua @@ -37,4 +37,10 @@ function EnnemyController:addBoss(ennData) self:add(boss) end +function EnnemyController:draw() + for i, villain in ipairs(self.list) do + villain:drawHUD() + end +end + return EnnemyController diff --git a/sonic-radiance.love/scenes/battlesystem/controllers/fighters/villain.lua b/sonic-radiance.love/scenes/battlesystem/controllers/fighters/villain.lua index 6751c1d..948a6cf 100644 --- a/sonic-radiance.love/scenes/battlesystem/controllers/fighters/villain.lua +++ b/sonic-radiance.love/scenes/battlesystem/controllers/fighters/villain.lua @@ -2,6 +2,7 @@ local FighterParent = require "scenes.battlesystem.controllers.fighters.parent" local VillainFighter = FighterParent:extend() local SimpleHPBar = require "game.modules.gui.simplehpbar" +local BossHPBar = require "game.modules.gui.bosshpbar" local EnnemyAction = require "scenes.battlesystem.controllers.fighters.systems.ennemyaction" local behaviourList = require "scenes.battlesystem.controllers.fighters.systems.behaviours" @@ -24,6 +25,11 @@ end function VillainFighter:updateAssets(dt) self.hpbar:update(dt) + if (self.bossHpBar ~= nil) then + self.bossHpBar:update(dt) + else + self.bossHpBar = BossHPBar(self.abstract.hp) + end end function VillainFighter:getAbstract() @@ -84,6 +90,7 @@ end function VillainFighter:setHP(value, relative) VillainFighter.super.setHP(self, value, relative) self.hpbar:setHP(self.abstract.hp) + self.bossHpBar:setHP(self.abstract.hp) end -- DRAW FUNCTIONS @@ -92,9 +99,17 @@ function VillainFighter:drawIcon(x, y) self.assets.fonts["hudnbrs_small"]:print(self.id, x+10, y+8) end -function VillainFighter:drawHUD(x, y) +function VillainFighter:drawOversprite(x, y) if (not self.isBoss) then self.hpbar:draw(x, y) + else + self.assets.images["crown"]:draw(x, y - 2) + end +end + +function VillainFighter:drawHUD() + if (self.isBoss and self.bossHpBar ~= nil) then + self.bossHpBar:draw(280, 28) end end