class MenuState

Attributes

play_state[RW]

Public Class Methods

new() click to toggle source
# File lib/game_states/menu_state.rb, line 6
def initialize
  @message = Gosu::Image.from_text(
    $window, "Tank Island",
    Utils.title_font, 60)
end

Public Instance Methods

button_down(id) click to toggle source
# File lib/game_states/menu_state.rb, line 46
def button_down(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() click to toggle source
# 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() click to toggle source
# File lib/game_states/menu_state.rb, line 12
def enter
  music.play(true)
  music.volume = 1
end
leave() click to toggle source
# File lib/game_states/menu_state.rb, line 17
def leave
  music.volume = 0
  music.stop
end
music() click to toggle source
# File lib/game_states/menu_state.rb, line 22
def music
  @@music ||= Gosu::Song.new(
    $window, Utils.media_path('menu_music.ogg'))
end
update() click to toggle source
# File lib/game_states/menu_state.rb, line 27
def update
  text = "Q: Quit\nN: New Game\nD: Demo"
  text << "\nC: Continue" if @play_state
  @info = Gosu::Image.from_text(
    $window, text,
    Utils.main_font, 30)
end