From 2bce318b9637342dac33b5f5411637d96a1517b1 Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Sun, 18 Apr 2021 18:23:52 +0200 Subject: [PATCH] feat: show health on overworld --- .../scenes/overworld/actors/player/health.lua | 23 +++++++++++++++++++ .../scenes/overworld/actors/player/init.lua | 4 ++++ sonic-radiance.love/scenes/overworld/init.lua | 6 +---- 3 files changed, 28 insertions(+), 5 deletions(-) create mode 100644 sonic-radiance.love/scenes/overworld/actors/player/health.lua diff --git a/sonic-radiance.love/scenes/overworld/actors/player/health.lua b/sonic-radiance.love/scenes/overworld/actors/player/health.lua new file mode 100644 index 0000000..6d63c82 --- /dev/null +++ b/sonic-radiance.love/scenes/overworld/actors/player/health.lua @@ -0,0 +1,23 @@ +local PlayerHealth = Object:extend() + +local ComplexHPBar = require "game.modules.gui.complexhpbar" + +local HPBAR_SIZE = 80 + +function PlayerHealth:initHealth() + self.hpbar = ComplexHPBar(HPBAR_SIZE) + self.hpbar:setColorForeground(248/255, 160/255, 0, 1) + self.hpbar:setColorBackground(112/255, 0, 0) +end + +function PlayerHealth:drawHealth(x, y) + for i, name in ipairs(game.characters.team) do + local yy = y + (i * 17) + local character = game.characters.list[name] + self.scene.assets.fonts["hudnbrs_small"]:set() + self.hpbar:drawWithLabels(x + 18, yy, character.hp, character.stats.hpmax) + self.assets.tileset["charicons"]:drawTile(character.data.icon, x, yy - 3) + end +end + +return PlayerHealth \ No newline at end of file diff --git a/sonic-radiance.love/scenes/overworld/actors/player/init.lua b/sonic-radiance.love/scenes/overworld/actors/player/init.lua index c7add90..857a361 100644 --- a/sonic-radiance.love/scenes/overworld/actors/player/init.lua +++ b/sonic-radiance.love/scenes/overworld/actors/player/init.lua @@ -7,12 +7,14 @@ local Interactions = require "scenes.overworld.actors.player.interactions" local Actions = require "scenes.overworld.actors.player.actions" local Charset = require "scenes.overworld.actors.player.charset" local Map = require "scenes.overworld.actors.player.map" +local Health = require "scenes.overworld.actors.player.health" Player:implement(Team) Player:implement(Interactions) Player:implement(Actions) Player:implement(Charset) Player:implement(Map) +Player:implement(Health) local FRICTION = 480 * 3 local GRAV = 10 @@ -36,6 +38,7 @@ function Player:new(world, x, y, id) self:initActions() self:initPlayerCharset() self:initMap() + self:initHealth() end function Player:updateStart(dt) @@ -112,6 +115,7 @@ function Player:timerResponse(response) end function Player:drawHUD(id) + self:drawHealth((424 - self.scene:getEmblemsPosition()) - 48, 168) self:drawEmblems(self.scene:getEmblemsPosition(), 24) end diff --git a/sonic-radiance.love/scenes/overworld/init.lua b/sonic-radiance.love/scenes/overworld/init.lua index d45109e..d4a9ade 100644 --- a/sonic-radiance.love/scenes/overworld/init.lua +++ b/sonic-radiance.love/scenes/overworld/init.lua @@ -35,8 +35,6 @@ local TweenManager = require "game.modules.tweenmanager" local EventManager = require "game.events" local MessageQueue = require "game.modules.messagequeue" -local PLAYER_MESSAGE = 240 - 32 - function OverWorld:new(area, playerx, playery) OverWorld.super.new(self) self.charsetManager = CharsetManager(self) @@ -64,8 +62,6 @@ function OverWorld:new(area, playerx, playery) self.timeBorder = -10 self.messages = MessageQueue(self) - self.message = "Test de message" - self.messageOpacity = 0 self.isPlaying = "" @@ -135,7 +131,7 @@ end function OverWorld:pause() self.tweens:newTween(0,0.2, {backGroundOpacity=0.75}, "inQuad") self.tweens:newTween(0,0.3, {borderPosition=30}, "inOutQuad") - self.tweens:newTween(0, 0.3, {emblemPosition=456}, "inOutQuad") + self.tweens:newTween(0, 0.3, {emblemPosition=500}, "inOutQuad") self.tweens:newTween(0, 0.3, {ringBorder=8}, "inOutQuad") self.tweens:newTween(0, 0.3, {timeBorder=19}, "inOutQuad") self.isPaused = true