feat: show health on overworld
This commit is contained in:
parent
a1d81b9170
commit
2bce318b96
3 changed files with 28 additions and 5 deletions
|
@ -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
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue