Use fonts everywhere, misc. tweaks

This commit is contained in:
2020-07-18 21:33:33 -05:00
parent ce90284001
commit 4ee97cca4b
11 changed files with 55 additions and 37 deletions

View File

@@ -1,26 +1,26 @@
class IMICFPS class IMICFPS
class CameraController class CameraController
include CommonMethods include CommonMethods
def initialize(mode: :fpv, camera:, entity:) def initialize(mode: :fpv, camera:, entity:)
# :fpv - First Person View # :fpv - First Person View
# :tpv - Third Person View # :tpv - Third Person View
@mode = mode @mode = mode
@camera = camera @camera = camera
@entity = entity @entity = entity
@distance = 4 @distance = 4
@origin_distance = @distance @origin_distance = @distance
@constant_pitch = 0 @constant_pitch = 20.0
window.mouse_x, window.mouse_y = window.width / 2, window.height / 2 window.mouse_x, window.mouse_y = window.width / 2, window.height / 2
@true_mouse = Point.new(window.width / 2, window.height / 2) @true_mouse = Point.new(window.width / 2, window.height / 2)
@mouse_sensitivity = 20.0 # Less is faster, more is slower @mouse_sensitivity = 20.0 # Less is faster, more is slower
@mouse_captured = true @mouse_captured = true
@mouse_checked = 0 @mouse_checked = 0
end end
def distance_from_object def distance_from_object
@distance @distance
end end
@@ -32,7 +32,7 @@ class IMICFPS
def vertical_distance_from_object def vertical_distance_from_object
distance_from_object * Math.sin(@constant_pitch) distance_from_object * Math.sin(@constant_pitch)
end end
def position_camera def position_camera
if defined?(@entity.first_person_view) if defined?(@entity.first_person_view)
if @entity.first_person_view if @entity.first_person_view
@@ -45,7 +45,7 @@ class IMICFPS
x_offset = horizontal_distance_from_object * Math.sin(@entity.orientation.y.degrees_to_radians) x_offset = horizontal_distance_from_object * Math.sin(@entity.orientation.y.degrees_to_radians)
z_offset = horizontal_distance_from_object * Math.cos(@entity.orientation.y.degrees_to_radians) z_offset = horizontal_distance_from_object * Math.cos(@entity.orientation.y.degrees_to_radians)
eye_height = @entity.bounding_box.max.y eye_height = @entity.normalize_bounding_box.max.y
@camera.position.x = @entity.position.x - x_offset @camera.position.x = @entity.position.x - x_offset
@camera.position.y = @entity.position.y + eye_height @camera.position.y = @entity.position.y + eye_height
@@ -53,10 +53,10 @@ class IMICFPS
@camera.orientation.y = 180 - @entity.orientation.y @camera.orientation.y = 180 - @entity.orientation.y
end end
def update def update
position_camera position_camera
if @mouse_captured if @mouse_captured
delta = Float(@true_mouse.x - self.mouse_x) / (@mouse_sensitivity * @camera.field_of_view) * 70 delta = Float(@true_mouse.x - self.mouse_x) / (@mouse_sensitivity * @camera.field_of_view) * 70
@camera.orientation.y -= delta @camera.orientation.y -= delta
@@ -73,7 +73,7 @@ class IMICFPS
@true_mouse.x, @true_mouse.y = window.mouse_x, window.mouse_y @true_mouse.x, @true_mouse.y = window.mouse_x, window.mouse_y
end end
end end
def button_down(id) def button_down(id)
case id case id
when Gosu::KB_LEFT_ALT, Gosu::KB_RIGHT_ALT when Gosu::KB_LEFT_ALT, Gosu::KB_RIGHT_ALT
@@ -84,7 +84,7 @@ class IMICFPS
window.needs_cursor = false window.needs_cursor = false
end end
end end
def button_up(id); end def button_up(id); end
end end
end end

View File

@@ -40,6 +40,7 @@ class IMICFPS
def backward def backward
@velocity.z -= Math.cos(relative_y_rotation * Math::PI / 180) * relative_speed @velocity.z -= Math.cos(relative_y_rotation * Math::PI / 180) * relative_speed
@velocity.y += Math.sin(@orientation.x * Math::PI / 180) * relative_speed
@velocity.x += Math.sin(relative_y_rotation * Math::PI / 180) * relative_speed @velocity.x += Math.sin(relative_y_rotation * Math::PI / 180) * relative_speed
end end
@@ -62,12 +63,11 @@ class IMICFPS
end end
def ascend def ascend
@velocity.y += 1 * delta_time @velocity.y += relative_speed
end end
alias :jump :ascend
def descend def descend
@velocity.y -= 1 * delta_time @velocity.y -= relative_speed
end end
def toggle_first_person_view def toggle_first_person_view

View File

@@ -61,7 +61,8 @@ class IMICFPS
data[:teams][1][:credits] = data[:players].select { |player| player[:team] == 1 }.map { |player| player[:credits] }.reduce(0, :+) data[:teams][1][:credits] = data[:players].select { |player| player[:team] == 1 }.map { |player| player[:credits] }.reduce(0, :+)
data[:teams][1][:score] = data[:players].select { |player| player[:team] == 1 }.map { |player| player[:score] }.reduce(0, :+) data[:teams][1][:score] = data[:players].select { |player| player[:team] == 1 }.map { |player| player[:score] }.reduce(0, :+)
data[:players].sort! { |player| player[:score] } data[:teams] = data[:teams].sort_by { |team| team[:score] }.reverse
data[:players] = data[:players].sort_by { |player| player[:score] }.reverse
return data return data
end end
@@ -75,14 +76,16 @@ class IMICFPS
text = "" text = ""
text += "# Team Credits Score\n" text += "# Team Credits Score\n"
data[:teams].each_with_index do |team, i| data[:teams].each_with_index do |team, i|
text += "<c=#{i.even? ? 'ffe66100' : 'ffa51d2d'}>#{i} #{team[:name]} #{i.even? ? team[:credits] : '-----'} #{team[:score]}</c>\n" i += 1
text += "<c=#{team[:name] == "Compass" ? 'ffe66100' : 'ffa51d2d'}>#{i} #{team[:name]} #{i.even? ? team[:credits] : '-----'} #{team[:score]}</c>\n"
end end
text += "\n" text += "\n"
text += "# Name Credits Score\n" text += "# Name Credits Score\n"
data[:players].each_with_index do |player, i| data[:players].each_with_index do |player, i|
text += "<c=#{i.even? ? 'ffe66100' : 'ffa51d2d'}>#{i} #{player[:username]} #{i.even? ? player[:credits] : '-----'} #{player[:score]}</c>\n" i += 1
text += "<c=#{player[:team].even? ? 'ffe66100' : 'ffa51d2d'}>#{i} #{player[:username]} #{player[:team].even? ? player[:credits] : '-----'} #{player[:score]}</c>\n"
end end
@text.text = text @text.text = text

View File

@@ -3,9 +3,18 @@ class IMICFPS
class SquadWidget < HUD::Widget class SquadWidget < HUD::Widget
def setup def setup
@size = 288 # RADAR size @size = 288 # RADAR size
@color = Gosu::Color.new(0x8800aa00) @color = Gosu::Color.new(0xff00aa00)
@text = Text.new("MATE\nTinyTanker\nOther Player Dude\nHuman 0xdeadbeef", size: 18, mode: :add, font: MONOSPACE_FONT, color: @color) @text = Text.new(
"MATE\nTinyTanker\nOther Player Dude\nHuman 0xdeadbeef",
size: 18,
mode: :add,
font: SANS_SERIF_FONT,
color: @color,
shadow: true,
shadow_color: 0x88000000,
shadow_size: 0.75
)
end end
def draw def draw

View File

@@ -58,10 +58,12 @@ eos
InputMapper.keys.each do |key, pressed| InputMapper.keys.each do |key, pressed|
next unless pressed next unless pressed
action = InputMapper.action(key) actions = InputMapper.action(key)
next unless action next unless actions
@player.send(action) if @player.respond_to?(action) actions.each do |action|
@player.send(action) if @player.respond_to?(action)
end
end end
end end

View File

@@ -11,10 +11,10 @@ class IMICFPS
end end
title IMICFPS::NAME title IMICFPS::NAME
@subheading = Text.new("Loading Map: #{@map_parser.metadata.name}", y: 100, size: 50, alignment: :center) @subheading = Text.new("Loading Map: #{@map_parser.metadata.name}", y: 100, size: 50, alignment: :center, font: SANS_SERIF_FONT)
@description = Text.new("Map created by: #{@map_parser.metadata.authors.join(", ")}\n#{@map_parser.metadata.description}", y: 180, size: 24, alignment: :center) @description = Text.new("Map created by: #{@map_parser.metadata.authors.join(", ")}\n#{@map_parser.metadata.description}", y: 180, size: 24, alignment: :center, font: SANS_SERIF_FONT)
@state = Text.new("Preparing...", y: window.height/2-40, size: 40, alignment: :center) @state = Text.new("Preparing...", y: window.height/2-40, size: 40, alignment: :center, font: SANS_SERIF_FONT)
@percentage = Text.new("0%", y: window.height - 100 + 25, size: 50, alignment: :center) @percentage = Text.new("0%", y: window.height - 100 + 25, size: 50, alignment: :center, font: MONOSPACE_FONT)
@dummy_entity = nil @dummy_entity = nil
@assets = [] @assets = []

View File

@@ -21,7 +21,7 @@ class IMICFPS
@light = Light.new(type: Light::DIRECTIONAL, id: available_light, position: Vector.new, diffuse: Vector.new(1, 1, 1, 1)) @light = Light.new(type: Light::DIRECTIONAL, id: available_light, position: Vector.new, diffuse: Vector.new(1, 1, 1, 1))
@lights << @light @lights << @light
@camera = Camera.new(position: Vector.new(0, 1.5, 5), orientation: Vector.forward) @camera = PerspectiveCamera.new(aspect_ratio: window.aspect_ratio, position: Vector.new(0, 1.5, 5), orientation: Vector.forward)
label @manifest.name, text_size: 50 label @manifest.name, text_size: 50
label @manifest.model label @manifest.model
@@ -56,7 +56,7 @@ class IMICFPS
def update def update
super super
@camera.update # @camera.update
@light.position = @camera.position.clone @light.position = @camera.position.clone
@light.position.y += 1.5 @light.position.y += 1.5
@camera_position.value = "Camera Position: X #{@camera.position.x.round(2)}, Y #{@camera.position.y.round(2)}, Z #{@camera.position.z.round(2)}" @camera_position.value = "Camera Position: X #{@camera.position.x.round(2)}, Y #{@camera.position.y.round(2)}, Z #{@camera.position.z.round(2)}"

View File

@@ -15,6 +15,7 @@ class IMICFPS
@crosshair = Crosshair.new @crosshair = Crosshair.new
@map.setup @map.setup
@map.add_entity(@editor)
end end
def draw def draw
@@ -45,7 +46,7 @@ class IMICFPS
end end
end end
@editor.update @editor.orientation.x = @camera.orientation.x
end end
def button_down(id) def button_down(id)

View File

@@ -10,10 +10,10 @@ class IMICFPS
@width = window.width / 4 * 3 @width = window.width / 4 * 3
@height = window.height / 4 * 3 @height = window.height / 4 * 3
@input = Text.new("", x: 4, y: @height - (PADDING * 2), z: Console::Z + 1) @input = Text.new("", x: 4, y: @height - (PADDING * 2), z: Console::Z + 1, font: MONOSPACE_FONT)
@input.y -= @input.height @input.y -= @input.height
@history = Text.new("=== #{IMICFPS::NAME} v#{IMICFPS::VERSION} (#{IMICFPS::RELEASE_NAME}) ===\n\n", x: 4, z: Console::Z + 1) @history = Text.new("=== #{IMICFPS::NAME} v#{IMICFPS::VERSION} (#{IMICFPS::RELEASE_NAME}) ===\n\n", x: 4, z: Console::Z + 1, font: MONOSPACE_FONT)
update_history_y update_history_y
@command_history = [] @command_history = []

View File

@@ -20,24 +20,27 @@ class IMICFPS
@accent_color = ACCENT_COLOR @accent_color = ACCENT_COLOR
window.needs_cursor = true window.needs_cursor = true
@__version_text = CyberarmEngine::Text.new("<b>#{IMICFPS::NAME}</b> v#{IMICFPS::VERSION} (#{IMICFPS::RELEASE_NAME})") @__version_text = CyberarmEngine::Text.new("<b>#{IMICFPS::NAME}</b> v#{IMICFPS::VERSION} (#{IMICFPS::RELEASE_NAME})", font: MONOSPACE_FONT)
@__version_text.x = window.width - (@__version_text.width + 10) @__version_text.x = window.width - (@__version_text.width + 10)
@__version_text.y = window.height - (@__version_text.height + 10) @__version_text.y = window.height - (@__version_text.height + 10)
super(*args) super(*args)
theme({ Label: { font: SANS_SERIF_FONT } })
end end
def title(text, color = Gosu::Color::BLACK) def title(text, color = Gosu::Color::BLACK)
@elements << Text.new(text, color: color, size: 100, x: 0, y: 15) @elements << Text.new(text, color: color, size: 100, x: 0, y: 15, font: SANS_SERIF_FONT)
@_title = @elements.last @_title = @elements.last
end end
def subtitle(text, color = Gosu::Color::WHITE) def subtitle(text, color = Gosu::Color::WHITE)
@elements << Text.new(text, color: color, size: 50, x: 0, y: 100) @elements << Text.new(text, color: color, size: 50, x: 0, y: 100, font: SANS_SERIF_FONT)
@_subtitle = @elements.last @_subtitle = @elements.last
end end
def link(text, color = Gosu::Color.rgb(0,127,127), &block) def link(text, color = Gosu::Color.rgb(0,127,127), &block)
text = Text.new(text, color: color, size: 50, x: 0, y: 100 + (60 * @elements.count)) text = Text.new(text, color: color, size: 50, x: 0, y: 100 + (60 * @elements.count), font: SANS_SERIF_FONT)
@elements << Link.new(text, self, block) @elements << Link.new(text, self, block)
end end

View File

@@ -17,7 +17,7 @@
"skydome":{ "skydome":{
"package":"base", "package":"base",
"name":"skydome", "name":"skydome",
"scale":0.08 "scale":0.37
}, },
"lights":[ "lights":[