class WelcomeState
Game state of main menu
Attributes
version[RW]
Public Instance Methods
draw()
click to toggle source
# File lib/lib/game_states/welcome_state.rb, line 49 def draw header_text = ' /-- /// /-/ -/- /-- ||| /-/ | /-- ||| | -/-' # Is there active map? Is it won? if PlayState.instance.map unless WinState.instance.faction resume_text = " Esc – resume" else resume_text = " Esc – return to victory screen" end else resume_text = "\n" end options_text = " 1 – start new: Map 01 2 – start new: Map 02 3 – start new: Map 03\n 9, S – settings 0, Q – quit" version_text = " version #{self.version}" menu = Gosu::Image.from_text( header_text + "\n\n\n" + resume_text + "\n" + options_text + "\n\n\n\n\n\n\n\n" + version_text, 20) menu.draw((3*TILESIZE) + XTEXT, (2*TILESIZE) + YTEXT, ZTEXT) end
update(button)
click to toggle source
Process given button
# File lib/lib/game_states/welcome_state.rb, line 24 def update(button) case(button) when Gosu::KbEscape then # If there is active map go either to it or to its win screen if PlayState.instance.map unless WinState.instance.faction GameState.switch!(PlayState.instance) else GameState.switch!(WinState.instance) end end when Gosu::Kb1, Gosu::Kb2, Gosu::Kb3 then PlayState.instance.desired_new_map = { Gosu::Kb1 => 'm01', Gosu::Kb2 => 'm02', Gosu::Kb3 => 'm03' }[button] GameState.switch!(PlayState.instance) when Gosu::Kb9, Gosu::KbS then GameState.switch!(SetState.instance) when Gosu::Kb0, Gosu::KbQ then GameState.switch!(QuitState.instance) end end