feat: improve battle hud spacing

Fix #22
This commit is contained in:
Kazhnuz 2020-08-04 18:50:36 +02:00
parent 58264e2a19
commit 5d34f55b23
6 changed files with 30 additions and 27 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 6 KiB

View file

@ -102,7 +102,7 @@ function ParallaxBackground:generateFloor(tile)
end
function ParallaxBackground:draw()
self:drawParallax(0, -self:getStartY(), 424, 240)
self:drawParallax(-maputils.CONST.STARTX, -self:getStartY(), 424, 240)
end
function ParallaxBackground:drawParallax(x, y, w, h)

View file

@ -37,8 +37,8 @@ function StatusBar:draw(x, y)
local hpmax = self.stats.hpmax
local ppmax = self.stats.ppmax
local bar1 = math.floor((self.hp/self.stats.hpmax)*107)
local bar2 = math.floor((self.pp/self.stats.ppmax)*108)
local bar1 = math.floor((self.hp/self.stats.hpmax)*58)
local bar2 = math.floor((self.pp/self.stats.ppmax)*58)
love.graphics.setColor(248/255, 160/255, 0, 1)
gui.drawBar(x+29, y+5, bar1, 7)
@ -56,7 +56,7 @@ function StatusBar:draw(x, y)
lvl = "0" .. lvl
end
love.graphics.print(lvl, x+122, y-5)
love.graphics.print(lvl, x+73, y-5)
end
return StatusBar

View file

@ -9,7 +9,7 @@ local POSITIONS = {3, 1, 5}
local HEROES_LINE = 2;
local HUDBASE = 8
local HUDSEP = 152
local HUDSIZE = 91
function HeroFighter:new(owner, character, id)
self.name = character
@ -44,7 +44,7 @@ function HeroFighter:getAbstract()
end
function HeroFighter:createActor()
local x, y = HEROES_LINE, POSITIONS[self.id]
local x, y = HEROES_LINE, ((self.id-1)*(4/(#game.characters.team-1))+1)
return self.world.obj.Hero(self.world, x, y, self)
end
@ -152,9 +152,10 @@ function HeroFighter:drawIcon(x, y)
end
function HeroFighter:drawHUD()
local x = HUDBASE + (self.id-1)*HUDSEP
local boxSize = 424 / 4
local x = (self.id-0.5)*boxSize
local y = self.turnSystem.hud:getPlayerHUDPosition()
self.statusbar:draw(x, y)
self.statusbar:draw(x - HUDSIZE/2, y)
end
return HeroFighter

View file

@ -3,6 +3,8 @@ local HUD = Object:extend()
local gui = require "game.modules.gui"
local TweenManager = require "game.modules.tweenmanager"
local PLAYER_HUD_HIDDEN = 240+64
local PLAYER_HUD_VISIBLE = 240-44
function HUD:new(turns)
self.turns = turns
@ -13,7 +15,7 @@ function HUD:new(turns)
self.frame = gui.newBorder(424, 30, 4)
self.tweens = TweenManager(self)
self.playerHUDPosition = -64
self.playerHUDPosition = PLAYER_HUD_HIDDEN
self.battlerCursor = self.turns.turns.current
end
@ -23,9 +25,9 @@ end
function HUD:movePlayerHUD(beginBattle)
if (beginBattle) then
self.tweens:newTween(0, 0.4, {playerHUDPosition = 16}, 'inCubic')
self.tweens:newTween(0, 0.4, {playerHUDPosition = PLAYER_HUD_VISIBLE}, 'inCubic')
else
self.tweens:newTween(0, 0.4, {playerHUDPosition = -64}, 'inCubic')
self.tweens:newTween(0, 0.4, {playerHUDPosition = PLAYER_HUD_HIDDEN}, 'inCubic')
end
end
@ -38,22 +40,9 @@ function HUD:getPlayerHUDPosition()
end
function HUD:draw()
for i, action in ipairs(self.turns.actionList) do
if action.fighter:canFight() then
action.fighter:drawIcon(4 + (i-1)*(20), 216)
else
self:drawEmptyIcon(4 + (i-1)*(20), 216)
end
end
local cursorx = self.battlerCursor * 20 - 8
local x, y = 4, 5
if #self.turns.actionList > 0 then
self.assets.images["menucursor"]:draw(cursorx, 216, math.rad(90), 1, 1, 4, 8)
end
local x, y = 362, 225
love.graphics.draw(self.frame, 424, 220, 0, -1, 1)
love.graphics.draw(self.frame, 0, 24, 0, 1, -1)
self.assets.images["hudturn"]:draw(x, y)
self.assets.fonts["hudnbrs"]:set()
local turnnbr = self.turns.turns.number
@ -61,6 +50,19 @@ function HUD:draw()
turnnbr = "0" .. turnnbr
end
love.graphics.print(turnnbr, x + 33, y + 1)
for i, action in ipairs(self.turns.actionList) do
if action.fighter:canFight() then
action.fighter:drawIcon(76 + (i-1)*(20), 5)
else
self:drawEmptyIcon(76 + (i-1)*(20), 5)
end
end
local cursorx = (self.battlerCursor-1) * 20 + 76
if #self.turns.actionList > 0 then
self.assets.images["menucursor"]:draw(cursorx, 5, math.rad(90), 1, 1, 4, 16)
end
end
function HUD:drawEmptyIcon(x, y)

View file

@ -10,7 +10,7 @@ local SubMenuWidget = BattleWidget:extend()
local BackMenuWidget = BattleWidget:extend()
local SkillWidget = BattleWidget:extend()
local MENUPOS_X1, MENUPOS_X2, MENUPOS_Y = 96, 32, 96
local MENUPOS_X1, MENUPOS_X2, MENUPOS_Y = 88, 32, 72
local MENU_WIDTH, MENU_ITEM_HEIGHT = 180, 17
local MENU_ITEM_NUMBER = 6