Class: WelcomeState
- Includes:
- Singleton
- Defined in:
- lib/lib/game_states/welcome_state.rb
Overview
Game state of closing the game window
Instance Method Summary collapse
- #draw ⇒ Object
-
#update(button) ⇒ Object
Process given button to cursor.
Methods inherited from GameState
#after_start, #before_end, switch!
Instance Method Details
#draw ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/lib/game_states/welcome_state.rb', line 38 def draw header_text = ' /-- /// /-/ -/- /-- ||| /-/ | /-- ||| | -/-' if PlayState.instance.map # some map is loaded space_text = "\n\n\n" = " Esc – Resume" else space_text = "\n\n\n\n" = "" end += " 1 – Start New: Map 01 2 – Start New: Map 02 3 – Start New: Map 03\n 0, Q – Quit" = Gosu::Image.from_text( header_text + space_text + , 20) .draw((3*TILESIZE) + XTEXT, (2*TILESIZE) + YTEXT, ZTEXT) end |
#update(button) ⇒ Object
Process given button to cursor
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/lib/game_states/welcome_state.rb', line 20 def update() case() when Gosu::Kb0, Gosu::KbQ then GameState.switch!(QuitState.instance) when Gosu::KbEscape then if PlayState.instance.map GameState.switch!(PlayState.instance) end when Gosu::Kb1, Gosu::Kb2, Gosu::Kb3 then PlayState.instance.desired_new_map = { Gosu::Kb1 => 'm01', Gosu::Kb2 => 'm02', Gosu::Kb3 => 'm03' }[] GameState.switch!(PlayState.instance) end end |