sonic-radiance/sonic-radiance.love/scenes/battlesystem/gui/hud.lua
2020-05-01 14:19:00 +02:00

65 lines
1.5 KiB
Lua

local HUD = Object:extend()
local gui = require "game.modules.gui"
local TweenManager = require "game.modules.tweenmanager"
function HUD:new(scene)
self.scene = scene
self.world = scene.world
self.assets = scene.assets
self.frame = gui.newBorder(424, 30, 4)
self.tweens = TweenManager(self)
self.playerHUDPosition = -64
self.battlerCursor = self.world.turns.current
end
function HUD:update(dt)
self.tweens:update(dt)
end
function HUD:movePlayerHUD(beginBattle)
if (beginBattle) then
self.tweens:newTween(0, 0.4, {playerHUDPosition = 36}, 'inCubic')
else
self.tweens:newTween(0, 0.4, {playerHUDPosition = -64}, 'inCubic')
end
end
function HUD:moveBattleCursor(moveCursorTo)
self.tweens:newTween(0, 0.2, {battlerCursor = moveCursorTo}, 'inCubic')
end
function HUD:getPlayerHUDPosition()
return self.playerHUDPosition
end
function HUD:draw()
for i, battler in ipairs(self.world.battlers) do
battler:drawHUD()
end
for i, action in ipairs(self.world.actionlist) do
action.actor:drawIcon(4 + (i-1)*(20), 6)
end
local cursorx = self.battlerCursor * 20 - 6
if #self.world.actionlist > 0 then
self.assets.images["menucursor"]:draw(cursorx, 26, math.rad(-90), 1, 1, 4, 8)
end
local x, y = 362, 3
love.graphics.draw(self.frame, 424, 20, 0, -1, -1)
self.assets.images["hudturn"]:draw(x, y)
self.assets.fonts["hudnbrs"]:set()
local turnnbr = self.world.turns.number
if (turnnbr < 10) then
turnnbr = "0" .. turnnbr
end
love.graphics.print(turnnbr, x + 33, y + 1)
end
return HUD