Added fonts and tweaked hud, added chat history and score board hud widgets

This commit is contained in:
2020-07-18 13:00:22 -05:00
parent b4a0a7a8bc
commit f6e4a509fd
17 changed files with 404 additions and 25 deletions

View File

@@ -3,13 +3,13 @@ class IMICFPS
class HealthWidget < HUD::Widget
def setup
@spacer = 0
@text = Text.new("")
@text = Text.new("", mode: :add, font: MONOSPACE_FONT)
@width = 512
@height = 24
@slant = 32
@color = Gosu::Color.rgba(100, 100, 200, 128)
@shield = Gosu::Color.rgba(200, 100, 50, 200)
@color = Gosu::Color.new(0x66ffa348)
@shield = Gosu::Color.new(0xaae66100)
@health = 0.0
end
@@ -17,19 +17,24 @@ class IMICFPS
def draw
@text.draw
fill_quad(
window.width / 2 - @width / 2, @spacer, # TOP LEFT
window.width / 2 + @width / 2, @spacer, # TOP RIGHT
window.width / 2 + @width / 2 - @slant, @spacer + @height, # BOTTOM RIGHT
window.width / 2 - @width / 2 + @slant, @spacer + @height, # BOTTOM LEFT
window.width / 2 - @width / 2, @spacer + @margin, # TOP LEFT
window.width / 2 + @width / 2, @spacer + @margin, # TOP RIGHT
window.width / 2 + @width / 2 - @slant, @spacer + @margin + @height, # BOTTOM RIGHT
window.width / 2 - @width / 2 + @slant, @spacer + @margin + @height, # BOTTOM LEFT
@color
)
bottom_right = (window.width / 2 - @width / 2) + @width * @health - @slant
if @width * @health - @slant < @slant
bottom_right = (window.width / 2 - @width / 2) + @slant
end
# Current Health
fill_quad(
window.width / 2 - @width / 2, @spacer, # TOP LEFT
(window.width / 2 - @width / 2) + @width * @health, @spacer, # TOP RIGHT
(window.width / 2 - @width / 2) + @width * @health - @slant, @spacer + @height, # BOTTOM RIGHT
window.width / 2 - @width / 2 + @slant, @spacer + @height, # BOTTOM LEFT
window.width / 2 - @width / 2, @spacer + @margin, # TOP LEFT
(window.width / 2 - @width / 2) + @width * @health, @spacer + @margin, # TOP RIGHT
bottom_right, @spacer + @margin + @height, # BOTTOM RIGHT
window.width / 2 - @width / 2 + @slant, @spacer + @margin + @height, # BOTTOM LEFT
@shield
)
end
@@ -38,7 +43,7 @@ class IMICFPS
percentage = "#{(@health * 100).round}".rjust(3, "0")
@text.text = "[Health #{percentage}%]"
@text.x = window.width / 2 - @text.width / 2
@text.y = @spacer + @height / 2 - @text.height / 2
@text.y = @spacer + @margin + @height / 2 - @text.height / 2
@health += 0.1 * window.dt
@health = 0 if @health > 1.0