feat(cbs): make HUD use existing datas
BIN
sonic-radiance.love/assets/gui/barborder.png
Normal file
After Width: | Height: | Size: 224 B |
BIN
sonic-radiance.love/assets/gui/emblem_power.png
Normal file
After Width: | Height: | Size: 4 KiB |
BIN
sonic-radiance.love/assets/gui/emblem_power_mask.png
Normal file
After Width: | Height: | Size: 4 KiB |
Before Width: | Height: | Size: 664 B After Width: | Height: | Size: 9.7 KiB |
BIN
sonic-radiance.love/assets/gui/emblem_speedster_mask.png
Normal file
After Width: | Height: | Size: 9.7 KiB |
BIN
sonic-radiance.love/assets/gui/emblem_technic.png
Normal file
After Width: | Height: | Size: 10 KiB |
BIN
sonic-radiance.love/assets/gui/emblem_technic_mask.png
Normal file
After Width: | Height: | Size: 10 KiB |
|
@ -1,4 +1,4 @@
|
|||
return {
|
||||
glyphs = " 0123456789",
|
||||
glyphs = " 0123456789/",
|
||||
extraspacing = 0,
|
||||
}
|
||||
|
|
Before Width: | Height: | Size: 521 B After Width: | Height: | Size: 4.6 KiB |
Before Width: | Height: | Size: 7 KiB After Width: | Height: | Size: 4.5 KiB |
|
@ -1,5 +1,7 @@
|
|||
local gui = {}
|
||||
|
||||
local barborder = love.graphics.newImage("assets/gui/barborder.png")
|
||||
|
||||
function gui.newBorder(width, height, middlePosition)
|
||||
local tileset = love.graphics.newImage("assets/gui/borders.png")
|
||||
local tilequad = {}
|
||||
|
@ -38,4 +40,13 @@ function gui.newBorder(width, height, middlePosition)
|
|||
return Texture
|
||||
end
|
||||
|
||||
function gui.drawBar(x, y, width, height)
|
||||
local height = height or 7
|
||||
love.graphics.setScissor(x, y, width, height)
|
||||
love.graphics.draw(barborder, x, y)
|
||||
love.graphics.rectangle("fill", x+7, y, width-14, height)
|
||||
love.graphics.draw(barborder, x+width-7, y, 0, -1, -1, 7, 7)
|
||||
love.graphics.setScissor( )
|
||||
end
|
||||
|
||||
return gui
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
local Battler = require("scenes.battlesystem.actors.battler")
|
||||
local Ennemy = Battler:extend()
|
||||
|
||||
local gui = require "game.modules.gui"
|
||||
|
||||
function Ennemy:new(world, x, y)
|
||||
Ennemy.super.new(self, world, x, y, 0)
|
||||
self.isEnnemy = true
|
||||
|
@ -9,12 +11,22 @@ function Ennemy:new(world, x, y)
|
|||
end
|
||||
|
||||
function Ennemy:draw()
|
||||
x, y = self.maputils.gridToPixel(self.x, self.y, true)
|
||||
local x, y = self.maputils.gridToPixel(self.x, self.y, true)
|
||||
love.graphics.setColor(1, 0, 0, 1)
|
||||
love.graphics.rectangle("fill", x - 8, y - 32, 16, 32)
|
||||
love.graphics.setColor(1, 1, 1, 1)
|
||||
end
|
||||
|
||||
function Ennemy:drawHUD()
|
||||
local x, y = self.maputils.gridToPixel(self.x, self.y, true)
|
||||
love.graphics.setColor(0, 0, 0, 1)
|
||||
gui.drawBar(x - 14, y - 38, 26, 4)
|
||||
love.graphics.setColor(248/255, 160/255, 0, 1)
|
||||
gui.drawBar(x - 14, y - 37, 24, 2)
|
||||
love.graphics.setColor(1, 1, 1, 1)
|
||||
|
||||
end
|
||||
|
||||
function Ennemy:drawIcon(x, y)
|
||||
love.graphics.setColor(1, 0, 0, 1)
|
||||
love.graphics.rectangle("fill", x, y, 16, 16)
|
||||
|
@ -23,7 +35,7 @@ end
|
|||
|
||||
function Ennemy:getStats()
|
||||
local stats = {}
|
||||
stats.speed = 100
|
||||
stats.speed = 25
|
||||
|
||||
return stats
|
||||
end
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
local Battler = require("scenes.battlesystem.actors.battler")
|
||||
local Hero = Battler:extend()
|
||||
|
||||
local gui = require "game.modules.gui"
|
||||
|
||||
-- INIT FUNCTIONS
|
||||
-- Initialize the hero
|
||||
|
||||
|
@ -209,12 +211,43 @@ function Hero:drawIcon(x, y)
|
|||
end
|
||||
|
||||
function Hero:drawHUD()
|
||||
local HUDBASE = -8
|
||||
local HUDBASE = 8
|
||||
local HUDSEP = 152
|
||||
local x = HUDBASE + (self.charnumber-1)*HUDSEP
|
||||
local y = 32
|
||||
local y = 36
|
||||
|
||||
self.assets.images["statusbar"]:draw(x, y)
|
||||
self.assets.images["e_speedster"]:draw(x, y)
|
||||
love.graphics.setScissor(x, y-16, 32, 40)
|
||||
self.assets.sprites[self.charid]:drawAnimation(x+14, y+14)
|
||||
love.graphics.setScissor( )
|
||||
self.assets.images["m_speedster"]:draw(x, y)
|
||||
self.assets.images["statusbar"]:draw(x+12, y-6)
|
||||
|
||||
local hp = game.characters.list[self.charid].stats.hp
|
||||
local pp = game.characters.list[self.charid].stats.pp
|
||||
local hpmax = game.characters.list[self.charid].stats.hpmax
|
||||
local ppmax = game.characters.list[self.charid].stats.ppmax
|
||||
|
||||
local bar1 = math.floor((hp/hpmax)*107)
|
||||
local bar2 = math.floor((pp/ppmax)*108)
|
||||
|
||||
love.graphics.setColor(248/255, 160/255, 0, 1)
|
||||
gui.drawBar(x+29, y+5, bar1, 7)
|
||||
love.graphics.setColor(0, 248/255, 248/255, 1)
|
||||
gui.drawBar(x+17, y+17, bar2, 7)
|
||||
utils.graphics.resetColor()
|
||||
|
||||
self.assets.fonts["hudnbrs_small"]:set()
|
||||
love.graphics.print(hp .. "/" .. hpmax, x+34, y+5)
|
||||
love.graphics.print(pp .. "/" .. ppmax, x+28, y+17)
|
||||
|
||||
local lvl = game.characters.list[self.charid].stats.level
|
||||
|
||||
if lvl < 100 then
|
||||
lvl = "0" .. lvl
|
||||
end
|
||||
|
||||
love.graphics.print(lvl, x+122, y-5)
|
||||
end
|
||||
|
||||
return Hero
|
||||
|
|
|
@ -13,7 +13,15 @@ return {
|
|||
{"statusbar", "assets/gui/status_bar.png"},
|
||||
{"cursorpeak", "assets/gui/cursor/peak.png"},
|
||||
{"actorsShadow", "assets/sprites/shadow.png"},
|
||||
{"emptytile", "assets/backgrounds/tilemask.png"}
|
||||
{"emptytile", "assets/backgrounds/tilemask.png"},
|
||||
|
||||
{"e_speedster", "assets/gui/emblem_speedster.png"},
|
||||
{"e_technic", "assets/gui/emblem_technic.png"},
|
||||
{"e_power", "assets/gui/emblem_power.png"},
|
||||
|
||||
{"m_speedster", "assets/gui/emblem_speedster_mask.png"},
|
||||
{"m_technic", "assets/gui/emblem_technic_mask.png"},
|
||||
{"m_power", "assets/gui/emblem_power_mask.png"},
|
||||
},
|
||||
["fonts"] = {
|
||||
{"small", "assets/gui/fonts/PixelOperator.ttf", 16},
|
||||
|
|