mirror of
https://github.com/cyberarm/i-mic-fps.git
synced 2025-12-15 15:42:35 +00:00
Ran rubocop autocorrect
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class IMICFPS
|
||||
class GameState < CyberarmEngine::GameState
|
||||
include CommonMethods
|
||||
|
||||
attr_reader :options
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class IMICFPS
|
||||
class Boot < GameState
|
||||
def setup
|
||||
@title = Text.new(IMICFPS::NAME, size: 100, z: 0, color: Gosu::Color.new(0xff000000), shadow: false, font: "Droid Serif")
|
||||
@logo = get_image(IMICFPS::GAME_ROOT_PATH + "/static/logo.png")
|
||||
@logo = get_image("#{IMICFPS::GAME_ROOT_PATH}/static/logo.png")
|
||||
|
||||
@start_time = Gosu.milliseconds
|
||||
@time_to_live = 3_000
|
||||
@@ -34,7 +35,7 @@ class IMICFPS
|
||||
|
||||
@title.draw
|
||||
|
||||
fill(Gosu::Color.rgba(0,0,0, 255 * (1.2 - fraction_left)))
|
||||
fill(Gosu::Color.rgba(0, 0, 0, 255 * (1.2 - fraction_left)))
|
||||
end
|
||||
end
|
||||
|
||||
@@ -46,11 +47,11 @@ class IMICFPS
|
||||
end
|
||||
|
||||
def button_up(id)
|
||||
if id == Gosu::KbEscape or
|
||||
(id >= Gosu::GP_LEFT and id >= Gosu::GP_BUTTON_15) or
|
||||
id == Gosu::MsLeft
|
||||
if (id == Gosu::KbEscape) ||
|
||||
((id >= Gosu::GP_LEFT) && (id >= Gosu::GP_BUTTON_15)) ||
|
||||
(id == Gosu::MsLeft)
|
||||
push_state(MainMenu)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class IMICFPS
|
||||
class Close < GameState
|
||||
def setup
|
||||
@slope = Menu::BAR_SLOPE
|
||||
|
||||
@logo = get_image(IMICFPS::GAME_ROOT_PATH + "/static/logo.png")
|
||||
@logo = get_image("#{IMICFPS::GAME_ROOT_PATH}/static/logo.png")
|
||||
|
||||
@start_time = Gosu.milliseconds
|
||||
@time_to_live = 3_000
|
||||
@@ -31,7 +32,7 @@ class IMICFPS
|
||||
|
||||
@logo.draw(window.width / 2 - @logo.width / 2, window.height / 2 - @logo.height / 2, 0)
|
||||
|
||||
fill(Gosu::Color.rgba(0,0,0, 255 * (1.1 - fraction_left)))
|
||||
fill(Gosu::Color.rgba(0, 0, 0, 255 * (1.1 - fraction_left)))
|
||||
end
|
||||
|
||||
def update
|
||||
@@ -40,11 +41,11 @@ class IMICFPS
|
||||
end
|
||||
|
||||
def button_up(id)
|
||||
if id == Gosu::KbEscape or
|
||||
(id >= Gosu::GP_LEFT and id >= Gosu::GP_BUTTON_15) or
|
||||
id == Gosu::MsLeft
|
||||
if (id == Gosu::KbEscape) ||
|
||||
((id >= Gosu::GP_LEFT) && (id >= Gosu::GP_BUTTON_15)) ||
|
||||
(id == Gosu::MsLeft)
|
||||
window.close!
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class IMICFPS
|
||||
class Game < GameState
|
||||
attr_reader :map
|
||||
@@ -7,7 +8,7 @@ class IMICFPS
|
||||
window.director.load_map(map_parser: @options[:map_parser])
|
||||
|
||||
@player = window.director.map.find_entity_by(name: "character")
|
||||
@camera = PerspectiveCamera.new( position: @player.position.clone, aspect_ratio: window.aspect_ratio )
|
||||
@camera = PerspectiveCamera.new(position: @player.position.clone, aspect_ratio: window.aspect_ratio)
|
||||
@camera_controller = CameraController.new(mode: :fpv, camera: @camera, entity: @player)
|
||||
|
||||
# @connection = Networking::Connection.new(address: "localhost", port: Networking::DEFAULT_SERVER_PORT)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class IMICFPS
|
||||
class LoadingState < Menu
|
||||
def setup
|
||||
@@ -13,8 +14,8 @@ class IMICFPS
|
||||
|
||||
title IMICFPS::NAME
|
||||
@subheading = Text.new("Loading Map: #{@map_parser.metadata.name}", y: 100, size: 50, alignment: :center, font: SANS_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_FONT)
|
||||
@state = Text.new("Preparing...", y: window.height/2-40, size: 40, alignment: :center, font: SANS_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_FONT)
|
||||
@state = Text.new("Preparing...", y: window.height / 2 - 40, size: 40, alignment: :center, font: SANS_FONT)
|
||||
@percentage = Text.new("0%", y: window.height - 100 + 25, size: 50, alignment: :center, font: SANS_FONT)
|
||||
|
||||
@dummy_entity = nil
|
||||
@@ -45,7 +46,6 @@ class IMICFPS
|
||||
@description.draw
|
||||
@state.draw
|
||||
|
||||
|
||||
progressbar
|
||||
end
|
||||
|
||||
@@ -75,18 +75,16 @@ class IMICFPS
|
||||
@asset_index += 1
|
||||
end
|
||||
|
||||
unless @asset_index < @assets.count
|
||||
if @act && Gosu.milliseconds-@completed_for_ms > 250
|
||||
push_state(@options[:forward], map_parser: @map_parser)
|
||||
else
|
||||
@act = true
|
||||
@completed_for_ms = Gosu.milliseconds unless @lock
|
||||
@lock = true
|
||||
end
|
||||
else
|
||||
if @asset_index < @assets.count
|
||||
@state.text = "Loading #{@assets[@asset_index][:type]} #{@assets[@asset_index][:name].split('/').last}..."
|
||||
@state.x = (window.width/2)-(@state.width/2)
|
||||
@state.x = (window.width / 2) - (@state.width / 2)
|
||||
@cycled = true
|
||||
elsif @act && Gosu.milliseconds - @completed_for_ms > 250
|
||||
push_state(@options[:forward], map_parser: @map_parser)
|
||||
else
|
||||
@act = true
|
||||
@completed_for_ms = Gosu.milliseconds unless @lock
|
||||
@lock = true
|
||||
end
|
||||
end
|
||||
|
||||
@@ -95,9 +93,9 @@ class IMICFPS
|
||||
when :model
|
||||
manifest = Manifest.new(manifest_file: IMICFPS.assets_path + "/#{package}/#{name}/manifest.yaml")
|
||||
add_required_assets(manifest)
|
||||
@assets << {type: type, manifest: manifest, package: package, name: name}
|
||||
@assets << { type: type, manifest: manifest, package: package, name: name }
|
||||
when :shader
|
||||
@assets << {type: type, manifest: manifest, package: package, name: name}
|
||||
@assets << { type: type, manifest: manifest, package: package, name: name }
|
||||
else
|
||||
raise TypeError "Unable to load asset of type #{type}"
|
||||
end
|
||||
@@ -105,30 +103,28 @@ class IMICFPS
|
||||
|
||||
def add_required_assets(manifest)
|
||||
manifest.uses.each do |dependency|
|
||||
known = @assets.detect {|asset| asset[:package] == dependency.package && asset[:name] == dependency.name}
|
||||
unless known
|
||||
add_asset(:model, dependency.package, dependency.name)
|
||||
end
|
||||
known = @assets.detect { |asset| asset[:package] == dependency.package && asset[:name] == dependency.name }
|
||||
add_asset(:model, dependency.package, dependency.name) unless known
|
||||
end
|
||||
end
|
||||
|
||||
def progressbar(x = window.width/4, y = window.height - 104)
|
||||
def progressbar(x = window.width / 4, y = window.height - 104)
|
||||
@percentage.draw
|
||||
progress = (@asset_index.to_f/@assets.count)*window.width/2
|
||||
progress = (@asset_index.to_f / @assets.count) * window.width / 2
|
||||
height = 100
|
||||
|
||||
dark_color= Gosu::Color.rgb(@primary_color.red - 100, @primary_color.green - 100, @primary_color.blue - 100)#Gosu::Color.rgb(64, 127, 255)
|
||||
color = Gosu::Color.rgb(@primary_color.red - 50, @primary_color.green - 50, @primary_color.blue - 50)#Gosu::Color.rgb(0,127,127)
|
||||
color_two = Gosu::Color.rgb(@primary_color.red + 50, @primary_color.green + 50, @primary_color.blue + 50)#Gosu::Color.rgb(64, 127, 255)
|
||||
dark_color = Gosu::Color.rgb(@primary_color.red - 100, @primary_color.green - 100, @primary_color.blue - 100) # Gosu::Color.rgb(64, 127, 255)
|
||||
color = Gosu::Color.rgb(@primary_color.red - 50, @primary_color.green - 50, @primary_color.blue - 50) # Gosu::Color.rgb(0,127,127)
|
||||
color_two = Gosu::Color.rgb(@primary_color.red + 50, @primary_color.green + 50, @primary_color.blue + 50) # Gosu::Color.rgb(64, 127, 255)
|
||||
|
||||
draw_rect(x, y-2, x + window.width/4, height+4, dark_color)
|
||||
draw_rect(x, y - 2, x + window.width / 4, height + 4, dark_color)
|
||||
|
||||
Gosu.clip_to(x, y, progress, height) do
|
||||
Gosu.draw_quad(
|
||||
x, y, color,
|
||||
x + x + window.width/4, y, color_two,
|
||||
x + x + window.width / 4, y, color_two,
|
||||
x, y + height, color,
|
||||
x + x + window.width/4, y + height, color_two
|
||||
x + x + window.width / 4, y + height, color_two
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user