Class: Chingu::GameStates::Debug
- Inherits:
-
Chingu::GameState
- Object
- Chingu::GameState
- Chingu::GameStates::Debug
- Includes:
- Helpers::OptionsSetter
- Defined in:
- lib/chingu/game_states/debug.rb
Overview
Debug game state (F1 is default key to start/exit debug win, 'p' to pause game)
Usage:
Constant Summary collapse
- Z =
TODO - centralize!
999- DEFAULTS =
{ :x_offset => 10, :y_offset => 10, :text_color => Gosu::Color.new(255,255,255,255), :fade_color => Gosu::Color.new(100,100,100,70), :paused => false }
Constants included from Helpers::GFX
Instance Attribute Summary collapse
-
#fade_color ⇒ Object
Returns the value of attribute fade_color.
-
#text ⇒ Object
Returns the value of attribute text.
-
#text_color ⇒ Object
Returns the value of attribute text_color.
-
#x_offset ⇒ Object
Returns the value of attribute x_offset.
-
#y_offset ⇒ Object
Returns the value of attribute y_offset.
Attributes inherited from Chingu::GameState
#game_objects, #game_state_manager, #options, #previous_game_state
Attributes included from Helpers::InputDispatcher
Instance Method Summary collapse
- #draw ⇒ Object
-
#initialize(options = {}) ⇒ Debug
constructor
A new instance of Debug.
- #pause ⇒ Object
- #return_to_game ⇒ Object
- #update ⇒ Object
Methods inherited from Chingu::GameState
#button_down, #button_up, #close, #close_game, #draw_trait, #filename, #setup, #setup_trait, #to_s, #to_sym, trait, #trait_options, traits, #update_trait
Methods included from Helpers::ClassInheritableAccessor
Methods included from Helpers::InputClient
#add_inputs, #holding?, #holding_all?, #holding_any?, #input, #input=, #on_input
Methods included from Helpers::InputDispatcher
#add_input_client, #dispatch_button_down, #dispatch_button_up, #dispatch_input_for, #remove_input_client
Methods included from Helpers::GameObject
#add_game_object, #game_objects, #game_objects_of_class, #hide_game_object, #load_game_objects, #pause_game_object, #remove_game_object, #save_game_objects, #show_game_object, #unpause_game_object
Methods included from Helpers::GameState
#clear_game_states, #current_game_state, #game_states, #pop_game_state, #push_game_state, #switch_game_state, #transitional_game_state
Methods included from Helpers::GFX
#draw_circle, #draw_rect, #fill, #fill_gradient, #fill_rect
Constructor Details
#initialize(options = {}) ⇒ Debug
Returns a new instance of Debug.
47 48 49 50 51 52 53 54 55 |
# File 'lib/chingu/game_states/debug.rb', line 47 def initialize( = {}) super (, DEFAULTS) # it fails when setup in DEFAULTS as it needs existing $window @font ||= Gosu::Font[16] self.input = {:p => :pause, :f1 => :return_to_game, :esc => :return_to_game} end |
Instance Attribute Details
#fade_color ⇒ Object
Returns the value of attribute fade_color.
34 35 36 |
# File 'lib/chingu/game_states/debug.rb', line 34 def fade_color @fade_color end |
#text ⇒ Object
Returns the value of attribute text.
34 35 36 |
# File 'lib/chingu/game_states/debug.rb', line 34 def text @text end |
#text_color ⇒ Object
Returns the value of attribute text_color.
34 35 36 |
# File 'lib/chingu/game_states/debug.rb', line 34 def text_color @text_color end |
#x_offset ⇒ Object
Returns the value of attribute x_offset.
34 35 36 |
# File 'lib/chingu/game_states/debug.rb', line 34 def x_offset @x_offset end |
#y_offset ⇒ Object
Returns the value of attribute y_offset.
34 35 36 |
# File 'lib/chingu/game_states/debug.rb', line 34 def y_offset @y_offset end |
Instance Method Details
#draw ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/chingu/game_states/debug.rb', line 69 def draw previous_state.draw unless previous_state.nil? $window.draw_quad( 0,0,@fade_color, $window.width,0,@fade_color, $window.width,$window.height,@fade_color, 0,$window.height,@fade_color,10) @font.draw("DEBUG CONSOLE", @x_offset, @y_offset, Z) print_lines(@text || generate_info) end |
#pause ⇒ Object
61 62 63 |
# File 'lib/chingu/game_states/debug.rb', line 61 def pause @paused = !@paused end |
#return_to_game ⇒ Object
57 58 59 |
# File 'lib/chingu/game_states/debug.rb', line 57 def return_to_game game_state_manager.pop_game_state end |
#update ⇒ Object
65 66 67 |
# File 'lib/chingu/game_states/debug.rb', line 65 def update game_state_manager.previous_game_state.update unless @paused end |