Class: MenuState
- Includes:
- Singleton
- Defined in:
- lib/game_states/menu_state.rb
Instance Attribute Summary collapse
-
#play_state ⇒ Object
Returns the value of attribute play_state.
Instance Method Summary collapse
- #button_down(id) ⇒ Object
- #draw ⇒ Object
- #enter ⇒ Object
-
#initialize ⇒ MenuState
constructor
A new instance of MenuState.
- #leave ⇒ Object
- #music ⇒ Object
- #update ⇒ Object
Methods inherited from GameState
Constructor Details
#initialize ⇒ MenuState
Returns a new instance of MenuState.
6 7 8 9 10 |
# File 'lib/game_states/menu_state.rb', line 6 def initialize @message = Gosu::Image.from_text( $window, "Tank Island", 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/menu_state.rb', line 4 def play_state @play_state end |
Instance Method Details
#button_down(id) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/game_states/menu_state.rb', line 46 def (id) $window.close if id == Gosu::KbQ if id == Gosu::KbC && @play_state GameState.switch(@play_state) end if id == Gosu::KbN @play_state = PlayState.new GameState.switch(@play_state) end if id == Gosu::KbD @play_state = DemoState.new GameState.switch(@play_state) end end |
#draw ⇒ Object
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/game_states/menu_state.rb', line 35 def draw @message.draw( $window.width / 2 - @message.width / 2, $window.height / 2 - @message.height / 2, 10) @info.draw( $window.width / 2 - @info.width / 2, $window.height / 2 - @info.height / 2 + 100, 10) end |
#enter ⇒ Object
12 13 14 15 |
# File 'lib/game_states/menu_state.rb', line 12 def enter music.play(true) music.volume = 1 end |
#leave ⇒ Object
17 18 19 20 |
# File 'lib/game_states/menu_state.rb', line 17 def leave music.volume = 0 music.stop end |
#music ⇒ Object
22 23 24 25 |
# File 'lib/game_states/menu_state.rb', line 22 def music @@music ||= Gosu::Song.new( $window, Utils.media_path('menu_music.ogg')) end |