diff --git a/README.md b/README.md
index a8b0200..5f3acb9 100644
--- a/README.md
+++ b/README.md
@@ -9,7 +9,6 @@ Requires a Ruby runtime that supports the gosu and opengl-bindings C-extensions
### Options
* `--native` - Launch in fullscreen using primary displays resolution
-* `--debug` - Set $debug variable to true (defaults to false)
* `--profile` - Run ruby-prof profiler
* `--savedemo` - Record camera movement and key events to playback later *(alpha-quality feature)*
* `--playdemo` - Plays the previously recorded demo *(alpha-quality feature)*
\ No newline at end of file
diff --git a/i-mic-fps.rb b/i-mic-fps.rb
index 9a69d81..1a73395 100644
--- a/i-mic-fps.rb
+++ b/i-mic-fps.rb
@@ -61,8 +61,6 @@ if RUBY_VERSION < "2.5.0"
end
end
-$debug = ARGV.join.include?("--debug") ? true : false
-
class IMICFPS
GAME_ROOT_PATH = File.expand_path(File.dirname(__FILE__))
end
diff --git a/lib/objects/light.rb b/lib/objects/light.rb
index e926934..95aa299 100644
--- a/lib/objects/light.rb
+++ b/lib/objects/light.rb
@@ -22,7 +22,7 @@ class IMICFPS
def available_light
raise "Using to many lights, #{@game_state.light_count}/#{LightManager::MAX_LIGHTS}" if @game_state.light_count > LightManager::MAX_LIGHTS
- puts "OpenGL::GL_LIGHT#{@game_state.light_count}" if $debug
+ puts "OpenGL::GL_LIGHT#{@game_state.light_count}" if $debug.get(:stats)
@light_id = Object.const_get "OpenGL::GL_LIGHT#{@game_state.light_count}"
end
diff --git a/lib/renderer/opengl_renderer.rb b/lib/renderer/opengl_renderer.rb
index 3f1b4df..03e312f 100644
--- a/lib/renderer/opengl_renderer.rb
+++ b/lib/renderer/opengl_renderer.rb
@@ -70,7 +70,7 @@ class IMICFPS
# glBindBuffer(GL_ARRAY_BUFFER, model.vertices_buffer)
# glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, 0)
- if $debug # This is kinda expensive
+ if $debug.get(:wireframe) # This is kinda expensive
glDisable(GL_LIGHTING)
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE)
glPolygonOffset(2, 0.5)
diff --git a/lib/renderer/renderer.rb b/lib/renderer/renderer.rb
index d9d078e..83b9c5a 100644
--- a/lib/renderer/renderer.rb
+++ b/lib/renderer/renderer.rb
@@ -17,14 +17,14 @@ class IMICFPS
@game_state.entities.each do |object|
if object.visible && object.renderable
# Render bounding boxes before transformation is applied
- @bounding_box_renderer.create_bounding_box(object, object.model.bounding_box, object.debug_color, object.object_id) if $debug
+ @bounding_box_renderer.create_bounding_box(object, object.model.bounding_box, object.debug_color, object.object_id) if $debug.get(:boundingboxes)
@opengl_renderer.draw_object(object)
end
end
- @bounding_box_renderer.draw_bounding_boxes if $debug
- window.number_of_vertices+=@bounding_box_renderer.vertex_count if $debug
+ @bounding_box_renderer.draw_bounding_boxes if $debug.get(:boundingboxes)
+ window.number_of_vertices+=@bounding_box_renderer.vertex_count if $debug.get(:boundingboxes)
# @bounding_box_renderer.bounding_boxes.clear
end
diff --git a/lib/states/game_states/game.rb b/lib/states/game_states/game.rb
index 347feb4..959817b 100644
--- a/lib/states/game_states/game.rb
+++ b/lib/states/game_states/game.rb
@@ -168,7 +168,6 @@ Vertices: #{formatted_number(window.number_of_vertices)}
Faces: #{formatted_number(window.number_of_vertices/3)}
Draw Skydome: #{@draw_skydome}
-Debug mode: #{$debug}
eos
rescue ArgumentError
string = <<-eos
@@ -185,14 +184,18 @@ Vertices: #{formatted_number(window.number_of_vertices)}
Faces: #{formatted_number(window.number_of_vertices/3)}
Draw Skydome: #{@draw_skydome}
-Debug mode: #{$debug}
eos
end
- if $debug
+ if $debug.get(:stats)
@text.text = string
- else
+ elsif $debug.get(:fps)
@text.text = "FPS: #{Gosu.fps}"
+ else
+ @text.text = ""
end
+
+ @draw_skydome = $debug.get(:skydome)
+ @skydome.renderable = @draw_skydome
end
def button_down(id)
@@ -227,14 +230,6 @@ eos
end
@camera.button_up(id)
-
- case id
- when Gosu::KbZ
- @draw_skydome = !@draw_skydome
- when Gosu::KbBacktick
- $debug = !$debug
- end
- @skydome.renderable = @draw_skydome
end
def needs_cursor?
diff --git a/lib/ui/command.rb b/lib/ui/command.rb
index 3a8ec8e..1fd6afd 100644
--- a/lib/ui/command.rb
+++ b/lib/ui/command.rb
@@ -5,7 +5,7 @@ class IMICFPS
"#{string}"
end
def self.warn(string)
- "#{string}"
+ "#{string}"
end
def self.notice(string)
"#{string}"
diff --git a/lib/ui/commands/debug_command.rb b/lib/ui/commands/debug_command.rb
index 6c1873c..b6b0158 100644
--- a/lib/ui/commands/debug_command.rb
+++ b/lib/ui/commands/debug_command.rb
@@ -10,13 +10,13 @@ class IMICFPS
end
def setup
+ $debug = self
+ set(:skydome, true)
+
subcommand(:boundingboxes, :boolean)
subcommand(:wireframe, :boolean)
- subcommand(:fps, :boolean)
subcommand(:stats, :boolean)
- subcommand(:motd, :string)
- subcommand(:mode, :integer)
- subcommand(:gravity, :decimal)
+ subcommand(:skydome, :boolean)
end
def handle(arguments, console)
diff --git a/lib/wavefront/model.rb b/lib/wavefront/model.rb
index 051293c..44a6027 100644
--- a/lib/wavefront/model.rb
+++ b/lib/wavefront/model.rb
@@ -41,7 +41,7 @@ class IMICFPS
parse
- puts "#{@file_path.split('/').last} took #{((Process.clock_gettime(Process::CLOCK_MONOTONIC, :float_millisecond)-start_time)/1000.0).round(2)} seconds to parse" if $debug
+ puts "#{@file_path.split('/').last} took #{((Process.clock_gettime(Process::CLOCK_MONOTONIC, :float_millisecond)-start_time)/1000.0).round(2)} seconds to parse" if $debug.get(:stats)
# allocate_gl_objects
# populate_buffers
@@ -49,7 +49,7 @@ class IMICFPS
@objects.each {|o| @vertex_count+=o.vertices.size}
@objects.each_with_index do |o, i|
- puts " Model::Object Name: #{o.name}, Vertices: #{o.vertices.size}" if $debug
+ puts " Model::Object Name: #{o.name}, Vertices: #{o.vertices.size}" if $debug.get(:stats)
end
window.number_of_vertices+=@vertex_count
@has_texture = false
@@ -130,7 +130,7 @@ class IMICFPS
box.max += Vector.new( 0.1, 0.1, 0.1)
@aabb_tree.insert(face, box)
end
- puts @aabb_tree.inspect if $debug
+ puts @aabb_tree.inspect if $debug.get(:stats)
end
def update
diff --git a/lib/wavefront/parser.rb b/lib/wavefront/parser.rb
index 1224361..4fc956e 100644
--- a/lib/wavefront/parser.rb
+++ b/lib/wavefront/parser.rb
@@ -62,7 +62,7 @@ class IMICFPS
end
end
- puts "Total Lines: #{lines}" if $debug
+ puts "Total Lines: #{lines}" if $debug.get(:stats)
calculate_bounding_box(@vertices, @bounding_box)
@objects.each do |o|
calculate_bounding_box(o.vertices, o.bounding_box)