diff --git a/lib/camera_controller.rb b/lib/camera_controller.rb index 45af8c2..075d73f 100644 --- a/lib/camera_controller.rb +++ b/lib/camera_controller.rb @@ -1,26 +1,26 @@ class IMICFPS class CameraController include CommonMethods - + def initialize(mode: :fpv, camera:, entity:) # :fpv - First Person View # :tpv - Third Person View @mode = mode @camera = camera @entity = entity - + @distance = 4 @origin_distance = @distance - @constant_pitch = 0 - + @constant_pitch = 20.0 + window.mouse_x, window.mouse_y = 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_captured = true @mouse_checked = 0 end - + def distance_from_object @distance end @@ -32,7 +32,7 @@ class IMICFPS def vertical_distance_from_object distance_from_object * Math.sin(@constant_pitch) end - + def position_camera if defined?(@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) 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.y = @entity.position.y + eye_height @@ -53,10 +53,10 @@ class IMICFPS @camera.orientation.y = 180 - @entity.orientation.y end - + def update position_camera - + if @mouse_captured delta = Float(@true_mouse.x - self.mouse_x) / (@mouse_sensitivity * @camera.field_of_view) * 70 @camera.orientation.y -= delta @@ -73,7 +73,7 @@ class IMICFPS @true_mouse.x, @true_mouse.y = window.mouse_x, window.mouse_y end end - + def button_down(id) case id when Gosu::KB_LEFT_ALT, Gosu::KB_RIGHT_ALT @@ -84,7 +84,7 @@ class IMICFPS window.needs_cursor = false end end - + def button_up(id); end end end diff --git a/lib/game_objects/entities/editor.rb b/lib/game_objects/entities/editor.rb index 5af890e..8b80e94 100644 --- a/lib/game_objects/entities/editor.rb +++ b/lib/game_objects/entities/editor.rb @@ -40,6 +40,7 @@ class IMICFPS def backward @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 end @@ -62,12 +63,11 @@ class IMICFPS end def ascend - @velocity.y += 1 * delta_time + @velocity.y += relative_speed end - alias :jump :ascend def descend - @velocity.y -= 1 * delta_time + @velocity.y -= relative_speed end def toggle_first_person_view diff --git a/lib/hud/widgets/score_board.rb b/lib/hud/widgets/score_board.rb index e2a3249..8d62243 100644 --- a/lib/hud/widgets/score_board.rb +++ b/lib/hud/widgets/score_board.rb @@ -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][: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 end @@ -75,14 +76,16 @@ class IMICFPS text = "" text += "# Team Credits Score\n" data[:teams].each_with_index do |team, i| - text += "#{i} #{team[:name]} #{i.even? ? team[:credits] : '-----'} #{team[:score]}\n" + i += 1 + text += "#{i} #{team[:name]} #{i.even? ? team[:credits] : '-----'} #{team[:score]}\n" end text += "\n" text += "# Name Credits Score\n" data[:players].each_with_index do |player, i| - text += "#{i} #{player[:username]} #{i.even? ? player[:credits] : '-----'} #{player[:score]}\n" + i += 1 + text += "#{i} #{player[:username]} #{player[:team].even? ? player[:credits] : '-----'} #{player[:score]}\n" end @text.text = text diff --git a/lib/hud/widgets/squad.rb b/lib/hud/widgets/squad.rb index 88c8fbc..ffa4d3b 100644 --- a/lib/hud/widgets/squad.rb +++ b/lib/hud/widgets/squad.rb @@ -3,9 +3,18 @@ class IMICFPS class SquadWidget < HUD::Widget def setup @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 def draw diff --git a/lib/states/game_states/game.rb b/lib/states/game_states/game.rb index 8d9e3b9..b6cc5c1 100644 --- a/lib/states/game_states/game.rb +++ b/lib/states/game_states/game.rb @@ -58,10 +58,12 @@ eos InputMapper.keys.each do |key, pressed| next unless pressed - action = InputMapper.action(key) - next unless action + actions = InputMapper.action(key) + 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 diff --git a/lib/states/game_states/loading_state.rb b/lib/states/game_states/loading_state.rb index 6eb1472..35df049 100644 --- a/lib/states/game_states/loading_state.rb +++ b/lib/states/game_states/loading_state.rb @@ -11,10 +11,10 @@ class IMICFPS end title IMICFPS::NAME - @subheading = Text.new("Loading Map: #{@map_parser.metadata.name}", y: 100, size: 50, alignment: :center) - @description = Text.new("Map created by: #{@map_parser.metadata.authors.join(", ")}\n#{@map_parser.metadata.description}", y: 180, size: 24, alignment: :center) - @state = Text.new("Preparing...", y: window.height/2-40, size: 40, alignment: :center) - @percentage = Text.new("0%", y: window.height - 100 + 25, 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, font: SANS_SERIF_FONT) + @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, font: MONOSPACE_FONT) @dummy_entity = nil @assets = [] diff --git a/lib/tools/asset_viewer/lib/turn_table.rb b/lib/tools/asset_viewer/lib/turn_table.rb index 25e4f2b..7da44c5 100644 --- a/lib/tools/asset_viewer/lib/turn_table.rb +++ b/lib/tools/asset_viewer/lib/turn_table.rb @@ -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)) @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.model @@ -56,7 +56,7 @@ class IMICFPS def update super - @camera.update + # @camera.update @light.position = @camera.position.clone @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)}" diff --git a/lib/tools/map_editor/lib/editor.rb b/lib/tools/map_editor/lib/editor.rb index 211662a..5716169 100644 --- a/lib/tools/map_editor/lib/editor.rb +++ b/lib/tools/map_editor/lib/editor.rb @@ -15,6 +15,7 @@ class IMICFPS @crosshair = Crosshair.new @map.setup + @map.add_entity(@editor) end def draw @@ -45,7 +46,7 @@ class IMICFPS end end - @editor.update + @editor.orientation.x = @camera.orientation.x end def button_down(id) diff --git a/lib/ui/console.rb b/lib/ui/console.rb index 52b5106..3a53ce0 100644 --- a/lib/ui/console.rb +++ b/lib/ui/console.rb @@ -10,10 +10,10 @@ class IMICFPS @width = window.width / 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 - @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 @command_history = [] diff --git a/lib/ui/menu.rb b/lib/ui/menu.rb index 81c8800..fdc5eb3 100644 --- a/lib/ui/menu.rb +++ b/lib/ui/menu.rb @@ -20,24 +20,27 @@ class IMICFPS @accent_color = ACCENT_COLOR window.needs_cursor = true - @__version_text = CyberarmEngine::Text.new("#{IMICFPS::NAME} v#{IMICFPS::VERSION} (#{IMICFPS::RELEASE_NAME})") + @__version_text = CyberarmEngine::Text.new("#{IMICFPS::NAME} v#{IMICFPS::VERSION} (#{IMICFPS::RELEASE_NAME})", font: MONOSPACE_FONT) @__version_text.x = window.width - (@__version_text.width + 10) @__version_text.y = window.height - (@__version_text.height + 10) + super(*args) + + theme({ Label: { font: SANS_SERIF_FONT } }) end 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 end 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 end 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) end diff --git a/maps/islands_test_map.json b/maps/islands_test_map.json index 4291d57..710e79e 100644 --- a/maps/islands_test_map.json +++ b/maps/islands_test_map.json @@ -17,7 +17,7 @@ "skydome":{ "package":"base", "name":"skydome", - "scale":0.08 + "scale":0.37 }, "lights":[