Class: Chingu::GameStates::Pause

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

Overview

Premade game state for chingu - A simple pause state. Pause whenever with:

push_game_state(Chingu::GameStates::Pause)

requires the global $window set to the instance of Gosu::Window (automaticly handled if you use Chingu::Window)

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_up, #close, #close_game, #draw_trait, has_trait, has_traits, #setup, #setup_trait, #to_s, #to_sym, #trait_options, #update, #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 = {}) ⇒ Pause

Returns a new instance of Pause.



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

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



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

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

#drawObject



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

def draw
  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