chore: simplify hud handling
This commit is contained in:
parent
a8bd55a2c2
commit
da647237a7
5 changed files with 25 additions and 52 deletions
|
@ -21,7 +21,7 @@ function ActorManager:new(controller)
|
||||||
self.cursor = self.turns.current
|
self.cursor = self.turns.current
|
||||||
|
|
||||||
for i, v in ipairs(game.characters.team) do
|
for i, v in ipairs(game.characters.team) do
|
||||||
self:addCharacter(POSITIONS[i].x, POSITIONS[i].y, v)
|
self:addCharacter(POSITIONS[i].x, POSITIONS[i].y, v, i)
|
||||||
end
|
end
|
||||||
|
|
||||||
self:addEnnemy(10, 3, "motobug")
|
self:addEnnemy(10, 3, "motobug")
|
||||||
|
@ -131,6 +131,10 @@ function ActorManager:draw()
|
||||||
v.actor:drawIcon(4 + (i-1)*(20), 6)
|
v.actor:drawIcon(4 + (i-1)*(20), 6)
|
||||||
end
|
end
|
||||||
self.controller.assets.images["menucursor"]:draw(self.cursor * 20 - 6, 26, math.rad(-90), 1, 1, 4, 8)
|
self.controller.assets.images["menucursor"]:draw(self.cursor * 20 - 6, 26, math.rad(-90), 1, 1, 4, 8)
|
||||||
|
|
||||||
|
for i,v in ipairs(self.actorlist) do
|
||||||
|
v:drawHUD()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return ActorManager
|
return ActorManager
|
||||||
|
|
|
@ -1,36 +0,0 @@
|
||||||
local BattleHUD = Object:extend()
|
|
||||||
|
|
||||||
local gui = require "game.modules.gui"
|
|
||||||
|
|
||||||
function BattleHUD:new(controller)
|
|
||||||
self.controller = controller
|
|
||||||
|
|
||||||
self:loadAssets()
|
|
||||||
end
|
|
||||||
|
|
||||||
function BattleHUD:loadAssets()
|
|
||||||
self.frame = gui.newBorder(424, 30, 8)
|
|
||||||
end
|
|
||||||
|
|
||||||
function BattleHUD:destroy( )
|
|
||||||
self.frame:release( )
|
|
||||||
end
|
|
||||||
|
|
||||||
function BattleHUD:update(dt)
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
function BattleHUD:draw()
|
|
||||||
self.controller.assets.fonts["hudnbrs"]:set()
|
|
||||||
self:drawFrame()
|
|
||||||
--self.controller:resetFont( )
|
|
||||||
end
|
|
||||||
|
|
||||||
function BattleHUD:drawFrame()
|
|
||||||
love.graphics.draw(self.frame, 424, 20, 0, -1, -1)
|
|
||||||
self.controller.assets.images["statusbar"]:draw(-8, 32)
|
|
||||||
self.controller.assets.images["statusbar"]:draw(-8 + 128 + 24, 32)
|
|
||||||
self.controller.assets.images["statusbar"]:draw(-8 + 256 + 48, 32)
|
|
||||||
end
|
|
||||||
|
|
||||||
return BattleHUD
|
|
|
@ -58,4 +58,8 @@ function BaseEntity:drawShadow()
|
||||||
self.controller.assets.images["actorsShadow"]:draw(x, y, 0, 1, 1, 12, 5)
|
self.controller.assets.images["actorsShadow"]:draw(x, y, 0, 1, 1, 12, 5)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function BaseEntity:drawHUD()
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
return BaseEntity
|
return BaseEntity
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
local Actor = require("scenes.battlesystem.entities.actor")
|
local Actor = require("scenes.battlesystem.entities.actor")
|
||||||
local Character = Actor:extend()
|
local Character = Actor:extend()
|
||||||
|
|
||||||
function Character:new(controller, x, y, charid)
|
function Character:new(controller, x, y, charid, charnumber)
|
||||||
Character.super.new(self, controller, x, y, 0)
|
Character.super.new(self, controller, x, y, 0)
|
||||||
self.isHero = true
|
self.isHero = true
|
||||||
self.turnAction = nil
|
self.turnAction = nil
|
||||||
|
@ -19,6 +19,8 @@ function Character:new(controller, x, y, charid)
|
||||||
self.assets.sprites[self.charid]:setCustomSpeed(16)
|
self.assets.sprites[self.charid]:setCustomSpeed(16)
|
||||||
self:setAnimation("idle")
|
self:setAnimation("idle")
|
||||||
self:setSprite(charid, 32, 48, true)
|
self:setSprite(charid, 32, 48, true)
|
||||||
|
|
||||||
|
self.charnumber = charnumber or 1
|
||||||
end
|
end
|
||||||
|
|
||||||
function Character:setAnimation(animation)
|
function Character:setAnimation(animation)
|
||||||
|
@ -143,16 +145,13 @@ function Character:getBackSignal()
|
||||||
self:setAnimation("walk")
|
self:setAnimation("walk")
|
||||||
end
|
end
|
||||||
|
|
||||||
function Character:drawStatus(frame, x, y)
|
function Character:drawHUD()
|
||||||
love.graphics.draw(frame, x, y)
|
local HUDBASE = -8
|
||||||
local y1 = y + 8
|
local HUDSEP = 152
|
||||||
local x1 = x + 16
|
local x = HUDBASE + (self.charnumber-1)*HUDSEP
|
||||||
local x2 = x1 + 120
|
local y = 32
|
||||||
love.graphics.setColor(.05, .8, .05, 1)
|
|
||||||
for i=0, 3 do
|
self.controller.assets.images["statusbar"]:draw(x, y)
|
||||||
love.graphics.line(x1-i, y1+i, x2-i, y1+i)
|
|
||||||
end
|
|
||||||
utils.graphics.resetColor()
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return Character
|
return Character
|
||||||
|
|
|
@ -8,10 +8,14 @@ local HUD = require "scenes.battlesystem.controller.hud"
|
||||||
local Cursor = require "scenes.battlesystem.controller.cursor"
|
local Cursor = require "scenes.battlesystem.controller.cursor"
|
||||||
local MenuSystem = require "scenes.battlesystem.controller.menu"
|
local MenuSystem = require "scenes.battlesystem.controller.menu"
|
||||||
|
|
||||||
|
local gui = require "game.modules.gui"
|
||||||
|
|
||||||
|
|
||||||
function BattleSystem:new()
|
function BattleSystem:new()
|
||||||
BattleSystem.super.new(self)
|
BattleSystem.super.new(self)
|
||||||
|
|
||||||
self.assets:batchImport("scenes.battlesystem.assets")
|
self.assets:batchImport("scenes.battlesystem.assets")
|
||||||
|
self.frame = gui.newBorder(424, 30, 8)
|
||||||
|
|
||||||
self:initManagers()
|
self:initManagers()
|
||||||
|
|
||||||
|
@ -19,17 +23,14 @@ function BattleSystem:new()
|
||||||
end
|
end
|
||||||
|
|
||||||
function BattleSystem:initManagers()
|
function BattleSystem:initManagers()
|
||||||
--self.loader = Loader()
|
|
||||||
self.datas = {}
|
self.datas = {}
|
||||||
self.battlearena = BattleArena(self)
|
self.battlearena = BattleArena(self)
|
||||||
self.actormanager = ActorManager(self)
|
self.actormanager = ActorManager(self)
|
||||||
self.hud = HUD(self)
|
|
||||||
self.cursor = Cursor(self)
|
self.cursor = Cursor(self)
|
||||||
self.menu = MenuSystem(self)
|
self.menu = MenuSystem(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
function BattleSystem:update(dt)
|
function BattleSystem:update(dt)
|
||||||
self.hud:update(dt)
|
|
||||||
self.battlearena:update(dt)
|
self.battlearena:update(dt)
|
||||||
self.cursor:update(dt)
|
self.cursor:update(dt)
|
||||||
|
|
||||||
|
@ -41,7 +42,8 @@ function BattleSystem:draw()
|
||||||
self.cursor:drawBottom()
|
self.cursor:drawBottom()
|
||||||
self.battlearena:drawEntities()
|
self.battlearena:drawEntities()
|
||||||
self.cursor:drawTop()
|
self.cursor:drawTop()
|
||||||
self.hud:draw()
|
|
||||||
|
love.graphics.draw(self.frame, 424, 20, 0, -1, -1)
|
||||||
self.actormanager:draw()
|
self.actormanager:draw()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue