feat: new improvement status hud
This commit is contained in:
parent
5b1008dbe4
commit
3bc2ea3e41
9 changed files with 83 additions and 8 deletions
|
@ -1,4 +1,4 @@
|
||||||
return {
|
return {
|
||||||
glyphs = " 0123456789/",
|
glyphs = " 0123456789/%",
|
||||||
extraspacing = 0,
|
extraspacing = 0,
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 521 B After Width: | Height: | Size: 4.4 KiB |
Binary file not shown.
Before Width: | Height: | Size: 4.5 KiB After Width: | Height: | Size: 4.5 KiB |
6
sonic-bluestreak.love/assets/gui/status/weapons.lua
Normal file
6
sonic-bluestreak.love/assets/gui/status/weapons.lua
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
return {
|
||||||
|
metadata = {
|
||||||
|
height = 32,
|
||||||
|
width = 32
|
||||||
|
}
|
||||||
|
}
|
BIN
sonic-bluestreak.love/assets/gui/status/weapons.png
Normal file
BIN
sonic-bluestreak.love/assets/gui/status/weapons.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 15 KiB |
|
@ -3,9 +3,6 @@ local Frame = Object:extend()
|
||||||
function Frame:new()
|
function Frame:new()
|
||||||
self.guiborder = game.gui.newBorder(424, 20, 6)
|
self.guiborder = game.gui.newBorder(424, 20, 6)
|
||||||
self.guiborder2 = game.gui.newBorder(424, 40, 12)
|
self.guiborder2 = game.gui.newBorder(424, 40, 12)
|
||||||
self.emblem = love.graphics.newImage("assets/gui/status/emblem_speedster.png")
|
|
||||||
self.status = love.graphics.newImage("assets/gui/status/status_bar.png")
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function Frame:draw()
|
function Frame:draw()
|
||||||
|
@ -14,8 +11,6 @@ function Frame:draw()
|
||||||
utils.graphics.resetColor()
|
utils.graphics.resetColor()
|
||||||
love.graphics.draw(self.guiborder, 424, 20, 0, -1, -1)
|
love.graphics.draw(self.guiborder, 424, 20, 0, -1, -1)
|
||||||
love.graphics.draw(self.guiborder2, 424, 220, 0, 1, 1, 424, 0)
|
love.graphics.draw(self.guiborder2, 424, 220, 0, 1, 1, 424, 0)
|
||||||
love.graphics.draw(self.emblem, 8, 8, 0)
|
|
||||||
love.graphics.draw(self.status, 24, 16, 0)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return Frame
|
return Frame
|
||||||
|
|
60
sonic-bluestreak.love/game/modules/gui/status.lua
Normal file
60
sonic-bluestreak.love/game/modules/gui/status.lua
Normal file
|
@ -0,0 +1,60 @@
|
||||||
|
local StatusArea = Object:extend()
|
||||||
|
|
||||||
|
function StatusArea:new(character, type, hpmax)
|
||||||
|
self.type = "e_" .. type;
|
||||||
|
self.hpmax = hpmax;
|
||||||
|
self.hp = hpmax;
|
||||||
|
self.pp = 100;
|
||||||
|
self.ppmax = 100;
|
||||||
|
self.assets = character.assets
|
||||||
|
self.weapon = 0
|
||||||
|
self.rings = 0
|
||||||
|
end
|
||||||
|
|
||||||
|
function StatusArea:setWeapon(weapon)
|
||||||
|
self.weapon = weapon
|
||||||
|
end
|
||||||
|
|
||||||
|
function StatusArea:setRings(rings)
|
||||||
|
self.rings = rings
|
||||||
|
end
|
||||||
|
|
||||||
|
function StatusArea:setHp(hp)
|
||||||
|
self.hp = hp
|
||||||
|
end
|
||||||
|
|
||||||
|
function StatusArea:setPp(pp)
|
||||||
|
self.pp = pp
|
||||||
|
end
|
||||||
|
|
||||||
|
function StatusArea:draw(x, y)
|
||||||
|
local x = x or 0
|
||||||
|
local y = y or 0
|
||||||
|
|
||||||
|
self.assets.images[self.type]:draw(x, y)
|
||||||
|
if (self.weapon ~= 0) then
|
||||||
|
self.assets.tileset["weapons"]:drawTile(self.weapon, x-2, y-2)
|
||||||
|
end
|
||||||
|
|
||||||
|
self.assets.images["statusbar"]:draw(x+8, y-2)
|
||||||
|
|
||||||
|
local bar1 = math.floor((self.hp/self.hpmax)*107)
|
||||||
|
local bar2 = math.floor((self.pp/100)*108)
|
||||||
|
|
||||||
|
love.graphics.setColor(248/255, 160/255, 0, 1)
|
||||||
|
game.gui.drawBar(x+25, y+9, bar1, 7)
|
||||||
|
love.graphics.setColor(0, 248/255, 248/255, 1)
|
||||||
|
game.gui.drawBar(x+13, y+21, bar2, 7)
|
||||||
|
utils.graphics.resetColor()
|
||||||
|
|
||||||
|
self.assets.fonts["smallnumbers"]:set()
|
||||||
|
love.graphics.print(math.floor(self.hp) .. "/" .. self.hpmax, x+34, y+9)
|
||||||
|
love.graphics.print(math.floor(self.pp) .. "%", x+34, y+21)
|
||||||
|
|
||||||
|
self.assets.fonts["numbers"]:set()
|
||||||
|
love.graphics.print(utils.math.numberToString(self.rings, 3), x+88, y-5)
|
||||||
|
|
||||||
|
self.assets.images["hudring"]:draw(x+125, y-6)
|
||||||
|
end
|
||||||
|
|
||||||
|
return StatusArea
|
|
@ -1,16 +1,26 @@
|
||||||
return {
|
return {
|
||||||
["textures"] = {
|
["textures"] = {
|
||||||
{"shadow", "assets/sprites/shadow.png"}
|
{"shadow", "assets/sprites/shadow.png"},
|
||||||
|
{"e_power", "assets/gui/status/emblem_power.png"},
|
||||||
|
{"e_fly", "assets/gui/status/emblem_technic.png"},
|
||||||
|
{"e_speed", "assets/gui/status/emblem_speedster.png"},
|
||||||
|
{"statusbar", "assets/gui/status/status_bar.png"},
|
||||||
|
{"hudring", "assets/gui/hud/ring.png"}
|
||||||
},
|
},
|
||||||
["sprites"] = {
|
["sprites"] = {
|
||||||
{"ring", "assets/sprites/items/ring"}
|
{"ring", "assets/sprites/items/ring"}
|
||||||
},
|
},
|
||||||
["imagefonts"] = {
|
["imagefonts"] = {
|
||||||
{"menu", "assets/gui/fonts/SA2font"}
|
{"menu", "assets/gui/fonts/SA2font"},
|
||||||
|
{"numbers", "assets/gui/fonts/numbers"},
|
||||||
|
{"smallnumbers", "assets/gui/fonts/smallnumbers"},
|
||||||
},
|
},
|
||||||
["sfx"] = {
|
["sfx"] = {
|
||||||
{"navigate", "assets/sfx/menu/select.wav"},
|
{"navigate", "assets/sfx/menu/select.wav"},
|
||||||
{"confirm", "assets/sfx/menu/validate.wav"},
|
{"confirm", "assets/sfx/menu/validate.wav"},
|
||||||
{"cancel", "assets/sfx/menu/cancel.wav"},
|
{"cancel", "assets/sfx/menu/cancel.wav"},
|
||||||
|
},
|
||||||
|
["tilesets"] = {
|
||||||
|
{"weapons", "assets/gui/status/weapons"}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ local Parent = require(cwd .. "parent")
|
||||||
local Player = Parent:extend()
|
local Player = Parent:extend()
|
||||||
|
|
||||||
local Frame = require("game.modules.gui.frame")
|
local Frame = require("game.modules.gui.frame")
|
||||||
|
local Statusbar = require("game.modules.gui.status")
|
||||||
|
|
||||||
function Player:new(world, x, y, z, id)
|
function Player:new(world, x, y, z, id)
|
||||||
Player.super.new(self, world, "player", x, y, 0, 16, 12, 24, true)
|
Player.super.new(self, world, "player", x, y, 0, 16, 12, 24, true)
|
||||||
|
@ -20,6 +21,8 @@ function Player:init(id)
|
||||||
self.charName = self.scene:getCharacterName(self.playerID)
|
self.charName = self.scene:getCharacterName(self.playerID)
|
||||||
self:setSprite(self.charName, 8, 10)
|
self:setSprite(self.charName, 8, 10)
|
||||||
self:cloneSprite()
|
self:cloneSprite()
|
||||||
|
self.statusbar = Statusbar(self, "speed", 50)
|
||||||
|
self.statusbar:setWeapon(2)
|
||||||
end
|
end
|
||||||
|
|
||||||
function Player:updateStart(dt)
|
function Player:updateStart(dt)
|
||||||
|
@ -98,6 +101,7 @@ end
|
||||||
|
|
||||||
function Player:drawHUD(id)
|
function Player:drawHUD(id)
|
||||||
self.frame:draw()
|
self.frame:draw()
|
||||||
|
self.statusbar:draw(8, 12)
|
||||||
end
|
end
|
||||||
|
|
||||||
return Player
|
return Player
|
||||||
|
|
Loading…
Reference in a new issue