Class: Chingu::GameStates::Pause

Inherits:
Chingu::GameState show all
Defined in:
lib/chingu/game_states/pause.rb

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_up, #close, #close_game, #setup, #to_s, #to_sym, #update

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, #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

#fill, #fill_gradient, #fill_rect

Constructor Details

#initialize(options = {}) ⇒ Pause

Returns a new instance of Pause.



34
35
36
37
38
39
40
# File 'lib/chingu/game_states/pause.rb', line 34

def initialize(options = {})
  super
  @white = Color.new(255,255,255,255)
  @color = Gosu::Color.new(200,0,0,0)
  @font = Gosu::Font.new($window, default_font_name, 35)
  @text = "PAUSED - press key to continue"
end

Instance Method Details

#button_down(id) ⇒ Object



42
43
44
# File 'lib/chingu/game_states/pause.rb', line 42

def button_down(id)
  game_state_manager.pop_game_state(:setup => false)    # Return the previous game state, dont call setup()
end

#drawObject



46
47
48
49
50
51
52
53
54
# File 'lib/chingu/game_states/pause.rb', line 46

def draw
  game_state_manager.previous_game_state.draw    # Draw prev game state onto screen (in this case our level)
  $window.draw_quad(  0,0,@color,
                      $window.width,0,@color,
                      $window.width,$window.height,@color,
                      0,$window.height,@color,10)
                      
  @font.draw(@text, ($window.width/2 - @font.text_width(@text)/2), $window.height/2 - @font.height, 999)
end