Class: PauseState
- Inherits:
-
GameState
show all
- Includes:
- Singleton
- Defined in:
- lib/game_states/pause_state.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from GameState
#needs_redraw?, switch, #update
Constructor Details
Returns a new instance of PauseState.
6
7
8
9
10
|
# File 'lib/game_states/pause_state.rb', line 6
def initialize
@message = Gosu::Image.from_text(
$window, "Game Paused",
Utils.title_font, 60)
end
|
Instance Attribute Details
#play_state ⇒ Object
Returns the value of attribute play_state.
4
5
6
|
# File 'lib/game_states/pause_state.rb', line 4
def play_state
@play_state
end
|
Instance Method Details
49
50
51
52
53
54
55
56
57
58
59
60
|
# File 'lib/game_states/pause_state.rb', line 49
def button_down(id)
if id == Gosu::KbQ
MenuState.instance.play_state = @play_state
GameState.switch(MenuState.instance)
end
if id == Gosu::KbC && @play_state
GameState.switch(@play_state)
end
if id == Gosu::KbEscape
GameState.switch(@play_state)
end
end
|
#draw ⇒ Object
30
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/game_states/pause_state.rb', line 30
def draw
@play_state.draw
@message.draw(
$window.width / 2 - @message.width / 2,
$window.height / 4 - @message.height - 50,
1000)
info.draw(
$window.width / 2 - info.width / 2,
$window.height / 4 - info.height,
1000)
@score_display.draw
end
|
#enter ⇒ Object
12
13
14
15
16
17
|
# File 'lib/game_states/pause_state.rb', line 12
def enter
music.play(true)
music.volume = 1
@score_display = ScoreDisplay.new(@play_state.object_pool)
@mouse_coords = [$window.mouse_x, $window.mouse_y]
end
|
#info ⇒ Object
43
44
45
46
47
|
# File 'lib/game_states/pause_state.rb', line 43
def info
@info ||= Gosu::Image.from_text(
$window, 'Q: Quit to Main Menu',
Utils.main_font, 30)
end
|
#leave ⇒ Object
19
20
21
22
23
|
# File 'lib/game_states/pause_state.rb', line 19
def leave
music.volume = 0
music.stop
$window.mouse_x, $window.mouse_y = @mouse_coords
end
|
#music ⇒ Object
25
26
27
28
|
# File 'lib/game_states/pause_state.rb', line 25
def music
@@music ||= Gosu::Song.new(
$window, Utils.media_path('menu_music.mp3'))
end
|