parent
2f5c57f3d2
commit
ef788afd70
8 changed files with 54 additions and 2 deletions
BIN
sonic-radiance.love/assets/gui/crown.png
Normal file
BIN
sonic-radiance.love/assets/gui/crown.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 922 B |
BIN
sonic-radiance.love/assets/gui/hpbar_boss.png
Normal file
BIN
sonic-radiance.love/assets/gui/hpbar_boss.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 744 B |
BIN
sonic-radiance.love/assets/gui/strings/boss.png
Normal file
BIN
sonic-radiance.love/assets/gui/strings/boss.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 646 B |
30
sonic-radiance.love/game/modules/gui/bosshpbar.lua
Normal file
30
sonic-radiance.love/game/modules/gui/bosshpbar.lua
Normal file
|
@ -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
|
|
@ -22,7 +22,7 @@ function Ennemy:draw()
|
||||||
self:drawSprite(0, -self.z)
|
self:drawSprite(0, -self.z)
|
||||||
local x, y = self.world.map:gridToPixel(self.x, self.y, true)
|
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
|
if (self.isSelected) then
|
||||||
local height = 32
|
local height = 32
|
||||||
|
|
|
@ -37,6 +37,7 @@ return {
|
||||||
{"game", "assets/gui/strings/game.png"},
|
{"game", "assets/gui/strings/game.png"},
|
||||||
{"over", "assets/gui/strings/over.png"},
|
{"over", "assets/gui/strings/over.png"},
|
||||||
{"arrow", "assets/gui/arrow.png"},
|
{"arrow", "assets/gui/arrow.png"},
|
||||||
|
{"crown", "assets/gui/crown.png"}
|
||||||
},
|
},
|
||||||
["fonts"] = {
|
["fonts"] = {
|
||||||
{"small", "assets/gui/fonts/PixelOperator.ttf", 16},
|
{"small", "assets/gui/fonts/PixelOperator.ttf", 16},
|
||||||
|
|
|
@ -37,4 +37,10 @@ function EnnemyController:addBoss(ennData)
|
||||||
self:add(boss)
|
self:add(boss)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function EnnemyController:draw()
|
||||||
|
for i, villain in ipairs(self.list) do
|
||||||
|
villain:drawHUD()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
return EnnemyController
|
return EnnemyController
|
||||||
|
|
|
@ -2,6 +2,7 @@ local FighterParent = require "scenes.battlesystem.controllers.fighters.parent"
|
||||||
local VillainFighter = FighterParent:extend()
|
local VillainFighter = FighterParent:extend()
|
||||||
|
|
||||||
local SimpleHPBar = require "game.modules.gui.simplehpbar"
|
local SimpleHPBar = require "game.modules.gui.simplehpbar"
|
||||||
|
local BossHPBar = require "game.modules.gui.bosshpbar"
|
||||||
local EnnemyAction = require "scenes.battlesystem.controllers.fighters.systems.ennemyaction"
|
local EnnemyAction = require "scenes.battlesystem.controllers.fighters.systems.ennemyaction"
|
||||||
local behaviourList = require "scenes.battlesystem.controllers.fighters.systems.behaviours"
|
local behaviourList = require "scenes.battlesystem.controllers.fighters.systems.behaviours"
|
||||||
|
|
||||||
|
@ -24,6 +25,11 @@ end
|
||||||
|
|
||||||
function VillainFighter:updateAssets(dt)
|
function VillainFighter:updateAssets(dt)
|
||||||
self.hpbar:update(dt)
|
self.hpbar:update(dt)
|
||||||
|
if (self.bossHpBar ~= nil) then
|
||||||
|
self.bossHpBar:update(dt)
|
||||||
|
else
|
||||||
|
self.bossHpBar = BossHPBar(self.abstract.hp)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function VillainFighter:getAbstract()
|
function VillainFighter:getAbstract()
|
||||||
|
@ -84,6 +90,7 @@ end
|
||||||
function VillainFighter:setHP(value, relative)
|
function VillainFighter:setHP(value, relative)
|
||||||
VillainFighter.super.setHP(self, value, relative)
|
VillainFighter.super.setHP(self, value, relative)
|
||||||
self.hpbar:setHP(self.abstract.hp)
|
self.hpbar:setHP(self.abstract.hp)
|
||||||
|
self.bossHpBar:setHP(self.abstract.hp)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- DRAW FUNCTIONS
|
-- DRAW FUNCTIONS
|
||||||
|
@ -92,9 +99,17 @@ function VillainFighter:drawIcon(x, y)
|
||||||
self.assets.fonts["hudnbrs_small"]:print(self.id, x+10, y+8)
|
self.assets.fonts["hudnbrs_small"]:print(self.id, x+10, y+8)
|
||||||
end
|
end
|
||||||
|
|
||||||
function VillainFighter:drawHUD(x, y)
|
function VillainFighter:drawOversprite(x, y)
|
||||||
if (not self.isBoss) then
|
if (not self.isBoss) then
|
||||||
self.hpbar:draw(x, y)
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue