Class: SpaceInvaders::GameOverScreen

Inherits:
Base
  • Object
show all
Includes:
Centerable
Defined in:
lib/space_invaders/screens/game_over_screen.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#app

Instance Method Summary collapse

Methods included from Centerable

#horizontal_center_draw, #vertical_center_draw

Methods inherited from Base

#game_status

Constructor Details

#initialize(app) ⇒ GameOverScreen

Returns a new instance of GameOverScreen.



10
11
12
13
14
15
# File 'lib/space_invaders/screens/game_over_screen.rb', line 10

def initialize app
  super
  @game_over_message = Gosu::Image.from_text app, "G A M E   O V E R", App::DEFAULT_FONT, 50
  @press_play = Gosu::Image.from_text app, "PRESS SPACE TO PLAY AGAIN", App::DEFAULT_FONT, 30
  @press_play_counter = 0
end

Instance Attribute Details

#control_indexObject (readonly)

Returns the value of attribute control_index.



8
9
10
# File 'lib/space_invaders/screens/game_over_screen.rb', line 8

def control_index
  @control_index
end

#game_over_messageObject (readonly)

Returns the value of attribute game_over_message.



8
9
10
# File 'lib/space_invaders/screens/game_over_screen.rb', line 8

def game_over_message
  @game_over_message
end

#press_playObject (readonly)

Returns the value of attribute press_play.



8
9
10
# File 'lib/space_invaders/screens/game_over_screen.rb', line 8

def press_play
  @press_play
end

#resultObject (readonly)

Returns the value of attribute result.



8
9
10
# File 'lib/space_invaders/screens/game_over_screen.rb', line 8

def result
  @result
end

Instance Method Details

#drawObject



17
18
19
20
21
22
23
24
# File 'lib/space_invaders/screens/game_over_screen.rb', line 17

def draw
  set_result
  horizontal_center_draw game_over_message, 100
  horizontal_center_draw result, 200

  horizontal_center_draw press_play, 300 if press_play_counter.between?(30,60)
  update_press_play_counter
end