Class: SpaceInvaders::NextLevelScreen

Inherits:
Base
  • Object
show all
Includes:
Centerable
Defined in:
lib/space_invaders/screens/next_level_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) ⇒ NextLevelScreen

Returns a new instance of NextLevelScreen.



10
11
12
13
# File 'lib/space_invaders/screens/next_level_screen.rb', line 10

def initialize app
  super
  @next_level_message = Gosu::Image.from_text app, "NEXT LEVEL", App::DEFAULT_FONT, 50
end

Instance Attribute Details

#next_level_messageObject (readonly)

Returns the value of attribute next_level_message.



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

def next_level_message
  @next_level_message
end

Instance Method Details

#drawObject



15
16
17
18
19
20
21
22
# File 'lib/space_invaders/screens/next_level_screen.rb', line 15

def draw
  if time_passed?
    timer_stop!
    game_status.continue!
  else
    horizontal_center_draw next_level_message, 300
  end
end

#timer_start!Object



24
25
26
# File 'lib/space_invaders/screens/next_level_screen.rb', line 24

def timer_start!
  @timeout = Time.now
end

#timer_stop!Object



28
29
30
31
# File 'lib/space_invaders/screens/next_level_screen.rb', line 28

def timer_stop!
  app.invaders_container.reinitialize!
  @timeout = nil
end