Added more hud widgets for showing squadmates and crosshair, added crosshair image and source svg, hackish fix to make renderer resize on windows size change, added CameraController camera control is back in 😂

This commit is contained in:
2020-07-18 15:54:00 -05:00
parent f6e4a509fd
commit 1d7cd19b41
9 changed files with 282 additions and 22 deletions

View File

@@ -0,0 +1,36 @@
class IMICFPS
class HUD
class CrosshairWidget < HUD::Widget
def setup
@scale = 0.75
@color = Gosu::Color.new(0x44ffffff)
@image = Gosu::Image.new("#{GAME_ROOT_PATH}/static/crosshairs/crosshair.png")
@last_changed_time = Gosu.milliseconds
@change_interval = 1_500
@colors = [0xffffffff, 0xaaffffff, 0x88ffffff, 0x22ffffff]
end
def draw
@image.draw(
window.width / 2 - (@image.width * @scale) / 2,
window.height / 2 - (@image.height * @scale) / 2,
46,
@scale,
@scale,
@color
)
end
def update
if Gosu.milliseconds - @last_changed_time >= @change_interval
@last_changed_time = Gosu.milliseconds
@color = @colors.sample
end
end
end
end
end

View File

@@ -7,6 +7,8 @@ class IMICFPS
@radar_color = Gosu::Color.new(0x88212121)
@text = Text.new("RADAR", size: 18, mode: :add, font: MONOSPACE_FONT)
@image = Gosu::Image.new("#{CYBERARM_ENGINE_ROOT_PATH}/assets/textures/default.png", retro: true)
@scale = (@size - @padding * 2.0) / @image.width
end
def draw
@@ -21,15 +23,17 @@ class IMICFPS
@size - @padding * 2, @size - @padding * 2,
@radar_color
)
@image.draw(@margin + @padding, window.height - (@size + @margin) + @padding, 46, @scale, @scale, 0x88ffffff)
@text.draw
end
def update
@text.text = "RADAR: X #{@player.position.x.round(1)} Y #{@player.position.z.round(1)}"
@text.text = "RADAR: X #{@player.position.x.round(1)} Y #{@player.position.y.round(1)} Z #{@player.position.z.round(1)}"
@text.x = @margin + @size / 2 - @text.width / 2
@text.y = window.height - (@margin + @size + @text.height)
end
end
end
end
end

21
lib/hud/widgets/squad.rb Normal file
View File

@@ -0,0 +1,21 @@
class IMICFPS
class HUD
class SquadWidget < HUD::Widget
def setup
@size = 288 # RADAR size
@color = Gosu::Color.new(0x8800aa00)
@text = Text.new("MATE\nTinyTanker\nOther Player Dude\nHuman 0xdeadbeef", size: 18, mode: :add, font: MONOSPACE_FONT, color: @color)
end
def draw
@text.draw
end
def update
@text.x = @margin + @size + @padding
@text.y = window.height - (@margin + @text.height)
end
end
end
end