Class: MenuState
- Includes:
- Singleton
- Defined in:
- lib/gamestates/menu_state.rb
Overview
class MenuState
Instance Attribute Summary collapse
-
#multiplayer ⇒ Object
Returns the value of attribute multiplayer.
Instance Method Summary collapse
- #button_down(id) ⇒ Object
- #draw ⇒ Object
- #enter ⇒ Object
-
#initialize ⇒ MenuState
constructor
A new instance of MenuState.
- #leave ⇒ Object
- #update(_keymap) ⇒ Object
Methods inherited from GameState
Constructor Details
Instance Attribute Details
#multiplayer ⇒ Object
Returns the value of attribute multiplayer.
8 9 10 |
# File 'lib/gamestates/menu_state.rb', line 8 def multiplayer @multiplayer end |
Instance Method Details
#button_down(id) ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/gamestates/menu_state.rb', line 38 def (id) $window.close if id == Gosu::KbEscape if id == Gosu::KbLeftShift || id == Gosu::KbRightShift @multiplayer ^= true # prevraceni hodnoty bool end GameState.switch(PlayState.new(@multiplayer)) if id == Gosu::KbReturn || id == Gosu::KbEnter end |
#draw ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/gamestates/menu_state.rb', line 30 def draw @message.draw($window.width / 2 - @message.width / 2, $window.height / 2 - @message.height / 2 - 50, 10) @pl1.draw($window.width / 2 - @pl1.width / 2, $window.height / 2 - @pl1.height / 2 + 30, 10) @pl2.draw($window.width / 2 - @pl1.width / 2, $window.height / 2 - @pl2.height / 2 + 50, 10) @choice.draw($window.width / 2 - @pl1.width / 2 - 30, $window.height / 2 - @pl1.height / 2 + 30, 10) unless @multiplayer @choice.draw($window.width / 2 - @pl1.width / 2 - 30, $window.height / 2 - @pl2.height / 2 + 50, 10) if @multiplayer end |
#enter ⇒ Object
16 17 18 |
# File 'lib/gamestates/menu_state.rb', line 16 def enter # play some music end |
#leave ⇒ Object
20 21 22 |
# File 'lib/gamestates/menu_state.rb', line 20 def leave # play some music end |
#update(_keymap) ⇒ Object
24 25 26 27 28 |
# File 'lib/gamestates/menu_state.rb', line 24 def update(_keymap) @pl1 = Gosu::Image.from_text($window, '1 Player', $window.mediamanager.font, 16) @pl2 = Gosu::Image.from_text($window, '2 Players', $window.mediamanager.font, 16) @choice.update end |