Class: Chingu::GameStates::Debug

Inherits:
Chingu::GameState show all
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)

Constant Summary

Constants included from Helpers::GFX

Helpers::GFX::CIRCLE_STEP

Instance Attribute Summary

Attributes inherited from Chingu::GameState

#game_objects, #game_state_manager, #options

Attributes included from Helpers::InputDispatcher

#input_clients

Instance Method Summary collapse

Methods inherited from Chingu::GameState

#button_down, #button_up, #close, #close_game, #draw_trait, has_trait, has_traits, #setup, #setup_trait, #to_s, #to_sym, #trait_options, #update_trait

Methods included from Helpers::ClassInheritableAccessor

included

Methods included from Helpers::InputClient

#input, #input=

Methods included from Helpers::InputDispatcher

#add_input_client, #dispatch_action, #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, #load_game_objects, #remove_game_object

Methods included from Helpers::GameState

#clear_game_states, #current_game_state, #pop_game_state, #previous_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.



29
30
31
32
33
34
35
36
37
38
# File 'lib/chingu/game_states/debug.rb', line 29

def initialize(options)
  super
  @white = Color.new(255,255,255,255)
  @fade_color = Gosu::Color.new(100,255,255,255)
  
  @font = Gosu::Font.new($window, default_font_name, 15)
  @paused = true
  
  self.input = {:p => :pause, :f1 => :return_to_game, :esc => :return_to_game}
end

Instance Method Details

#drawObject



52
53
54
55
56
57
58
59
60
61
62
# File 'lib/chingu/game_states/debug.rb', line 52

def draw
  game_state_manager.previous_game_state.draw

  $window.draw_quad(  0,0,@fade_color,
                      $window.width,0,@fade_color,
                      $window.width,$window.height,@fade_color,
                      0,$window.height,@fade_color,10)
                 
  text = "DEBUG CONSOLE"
  @font.draw(text, $window.width - @font.text_width(text), @font.height, 999)
end

#pauseObject



44
45
46
# File 'lib/chingu/game_states/debug.rb', line 44

def pause
  @paused = @paused ? false : true
end

#return_to_gameObject



40
41
42
# File 'lib/chingu/game_states/debug.rb', line 40

def return_to_game
  game_state_manager.pop_game_state
end

#updateObject



48
49
50
# File 'lib/chingu/game_states/debug.rb', line 48

def update
  game_state_manager.previous_game_state.update unless @paused
end