mirror of
https://github.com/cyberarm/i-mic-fps.git
synced 2025-12-15 23:52:35 +00:00
Debug commands now affect game
This commit is contained in:
@@ -9,7 +9,6 @@ Requires a Ruby runtime that supports the gosu and opengl-bindings C-extensions
|
|||||||
|
|
||||||
### Options
|
### Options
|
||||||
* `--native` - Launch in fullscreen using primary displays resolution
|
* `--native` - Launch in fullscreen using primary displays resolution
|
||||||
* `--debug` - Set $debug variable to true (defaults to false)
|
|
||||||
* `--profile` - Run ruby-prof profiler
|
* `--profile` - Run ruby-prof profiler
|
||||||
* `--savedemo` - Record camera movement and key events to playback later *(alpha-quality feature)*
|
* `--savedemo` - Record camera movement and key events to playback later *(alpha-quality feature)*
|
||||||
* `--playdemo` - Plays the previously recorded demo *(alpha-quality feature)*
|
* `--playdemo` - Plays the previously recorded demo *(alpha-quality feature)*
|
||||||
@@ -61,8 +61,6 @@ if RUBY_VERSION < "2.5.0"
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
$debug = ARGV.join.include?("--debug") ? true : false
|
|
||||||
|
|
||||||
class IMICFPS
|
class IMICFPS
|
||||||
GAME_ROOT_PATH = File.expand_path(File.dirname(__FILE__))
|
GAME_ROOT_PATH = File.expand_path(File.dirname(__FILE__))
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ class IMICFPS
|
|||||||
|
|
||||||
def available_light
|
def available_light
|
||||||
raise "Using to many lights, #{@game_state.light_count}/#{LightManager::MAX_LIGHTS}" if @game_state.light_count > LightManager::MAX_LIGHTS
|
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}"
|
@light_id = Object.const_get "OpenGL::GL_LIGHT#{@game_state.light_count}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ class IMICFPS
|
|||||||
# glBindBuffer(GL_ARRAY_BUFFER, model.vertices_buffer)
|
# glBindBuffer(GL_ARRAY_BUFFER, model.vertices_buffer)
|
||||||
# glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, 0)
|
# 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)
|
glDisable(GL_LIGHTING)
|
||||||
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE)
|
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE)
|
||||||
glPolygonOffset(2, 0.5)
|
glPolygonOffset(2, 0.5)
|
||||||
|
|||||||
@@ -17,14 +17,14 @@ class IMICFPS
|
|||||||
@game_state.entities.each do |object|
|
@game_state.entities.each do |object|
|
||||||
if object.visible && object.renderable
|
if object.visible && object.renderable
|
||||||
# Render bounding boxes before transformation is applied
|
# 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)
|
@opengl_renderer.draw_object(object)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@bounding_box_renderer.draw_bounding_boxes if $debug
|
@bounding_box_renderer.draw_bounding_boxes if $debug.get(:boundingboxes)
|
||||||
window.number_of_vertices+=@bounding_box_renderer.vertex_count if $debug
|
window.number_of_vertices+=@bounding_box_renderer.vertex_count if $debug.get(:boundingboxes)
|
||||||
# @bounding_box_renderer.bounding_boxes.clear
|
# @bounding_box_renderer.bounding_boxes.clear
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -168,7 +168,6 @@ Vertices: #{formatted_number(window.number_of_vertices)}
|
|||||||
Faces: #{formatted_number(window.number_of_vertices/3)}
|
Faces: #{formatted_number(window.number_of_vertices/3)}
|
||||||
|
|
||||||
Draw Skydome: #{@draw_skydome}
|
Draw Skydome: #{@draw_skydome}
|
||||||
Debug mode: <c=992200>#{$debug}</c>
|
|
||||||
eos
|
eos
|
||||||
rescue ArgumentError
|
rescue ArgumentError
|
||||||
string = <<-eos
|
string = <<-eos
|
||||||
@@ -185,14 +184,18 @@ Vertices: #{formatted_number(window.number_of_vertices)}
|
|||||||
Faces: #{formatted_number(window.number_of_vertices/3)}
|
Faces: #{formatted_number(window.number_of_vertices/3)}
|
||||||
|
|
||||||
Draw Skydome: #{@draw_skydome}
|
Draw Skydome: #{@draw_skydome}
|
||||||
Debug mode: <c=992200>#{$debug}</c>
|
|
||||||
eos
|
eos
|
||||||
end
|
end
|
||||||
if $debug
|
if $debug.get(:stats)
|
||||||
@text.text = string
|
@text.text = string
|
||||||
else
|
elsif $debug.get(:fps)
|
||||||
@text.text = "FPS: #{Gosu.fps}"
|
@text.text = "FPS: #{Gosu.fps}"
|
||||||
|
else
|
||||||
|
@text.text = ""
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@draw_skydome = $debug.get(:skydome)
|
||||||
|
@skydome.renderable = @draw_skydome
|
||||||
end
|
end
|
||||||
|
|
||||||
def button_down(id)
|
def button_down(id)
|
||||||
@@ -227,14 +230,6 @@ eos
|
|||||||
end
|
end
|
||||||
|
|
||||||
@camera.button_up(id)
|
@camera.button_up(id)
|
||||||
|
|
||||||
case id
|
|
||||||
when Gosu::KbZ
|
|
||||||
@draw_skydome = !@draw_skydome
|
|
||||||
when Gosu::KbBacktick
|
|
||||||
$debug = !$debug
|
|
||||||
end
|
|
||||||
@skydome.renderable = @draw_skydome
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def needs_cursor?
|
def needs_cursor?
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ class IMICFPS
|
|||||||
"<c=ff5555>#{string}</c>"
|
"<c=ff5555>#{string}</c>"
|
||||||
end
|
end
|
||||||
def self.warn(string)
|
def self.warn(string)
|
||||||
"<c=ff5500>#{string}</c>"
|
"<c=ff7700>#{string}</c>"
|
||||||
end
|
end
|
||||||
def self.notice(string)
|
def self.notice(string)
|
||||||
"<c=55ff55>#{string}</c>"
|
"<c=55ff55>#{string}</c>"
|
||||||
|
|||||||
@@ -10,13 +10,13 @@ class IMICFPS
|
|||||||
end
|
end
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
|
$debug = self
|
||||||
|
set(:skydome, true)
|
||||||
|
|
||||||
subcommand(:boundingboxes, :boolean)
|
subcommand(:boundingboxes, :boolean)
|
||||||
subcommand(:wireframe, :boolean)
|
subcommand(:wireframe, :boolean)
|
||||||
subcommand(:fps, :boolean)
|
|
||||||
subcommand(:stats, :boolean)
|
subcommand(:stats, :boolean)
|
||||||
subcommand(:motd, :string)
|
subcommand(:skydome, :boolean)
|
||||||
subcommand(:mode, :integer)
|
|
||||||
subcommand(:gravity, :decimal)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def handle(arguments, console)
|
def handle(arguments, console)
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ class IMICFPS
|
|||||||
|
|
||||||
parse
|
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
|
# allocate_gl_objects
|
||||||
# populate_buffers
|
# populate_buffers
|
||||||
@@ -49,7 +49,7 @@ class IMICFPS
|
|||||||
|
|
||||||
@objects.each {|o| @vertex_count+=o.vertices.size}
|
@objects.each {|o| @vertex_count+=o.vertices.size}
|
||||||
@objects.each_with_index do |o, i|
|
@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
|
end
|
||||||
window.number_of_vertices+=@vertex_count
|
window.number_of_vertices+=@vertex_count
|
||||||
@has_texture = false
|
@has_texture = false
|
||||||
@@ -130,7 +130,7 @@ class IMICFPS
|
|||||||
box.max += Vector.new( 0.1, 0.1, 0.1)
|
box.max += Vector.new( 0.1, 0.1, 0.1)
|
||||||
@aabb_tree.insert(face, box)
|
@aabb_tree.insert(face, box)
|
||||||
end
|
end
|
||||||
puts @aabb_tree.inspect if $debug
|
puts @aabb_tree.inspect if $debug.get(:stats)
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ class IMICFPS
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
puts "Total Lines: #{lines}" if $debug
|
puts "Total Lines: #{lines}" if $debug.get(:stats)
|
||||||
calculate_bounding_box(@vertices, @bounding_box)
|
calculate_bounding_box(@vertices, @bounding_box)
|
||||||
@objects.each do |o|
|
@objects.each do |o|
|
||||||
calculate_bounding_box(o.vertices, o.bounding_box)
|
calculate_bounding_box(o.vertices, o.bounding_box)
|
||||||
|
|||||||
Reference in New Issue
Block a user