Class: LunarLander::Gameover

Inherits:
Chingu::GameState
  • Object
show all
Defined in:
lib/lunar_lander/game_states/gameover.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Gameover

Returns a new instance of Gameover.



4
5
6
7
8
9
10
11
12
13
# File 'lib/lunar_lander/game_states/gameover.rb', line 4

def initialize(options = {})
  super
  
  @white = Gosu::Color.new(255,255,255,255)
  @color = Gosu::Color.new(200,0,0,0)
  @font = Gosu::Font[35]
  @text = ["Perdeu playboy!","Pressione 'n' para tentar novamente."]
  
  self.input = { :n => :new_game }
end

Instance Method Details

#drawObject



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/lunar_lander/game_states/gameover.rb', line 19

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, Chingu::DEBUG_ZORDER)
  
  @text.each_with_index do |text, index|                    
    @font.draw(text, ($window.width/2 - @font.text_width(text)/2), $window.height/2 - (@font.height - (index * @font.height)), Chingu::DEBUG_ZORDER + 1)
  end
end

#new_gameObject



15
16
17
# File 'lib/lunar_lander/game_states/gameover.rb', line 15

def new_game
  switch_game_state LunarLander::Play
end