mirror of
https://github.com/cyberarm/i-mic-fps.git
synced 2025-12-15 07:32: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
|
||||
* `--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)*
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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: <c=992200>#{$debug}</c>
|
||||
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: <c=992200>#{$debug}</c>
|
||||
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?
|
||||
|
||||
@@ -5,7 +5,7 @@ class IMICFPS
|
||||
"<c=ff5555>#{string}</c>"
|
||||
end
|
||||
def self.warn(string)
|
||||
"<c=ff5500>#{string}</c>"
|
||||
"<c=ff7700>#{string}</c>"
|
||||
end
|
||||
def self.notice(string)
|
||||
"<c=55ff55>#{string}</c>"
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user