Class: MainMenuScene
Instance Attribute Summary
Attributes inherited from Scene
Instance Method Summary collapse
- #add_continue ⇒ Object
- #button_down(id) ⇒ Object
- #difficulty ⇒ Object
- #down ⇒ Object
- #draw ⇒ Object
-
#initialize(window) ⇒ MainMenuScene
constructor
A new instance of MainMenuScene.
- #remove_continue ⇒ Object
- #up ⇒ Object
Methods inherited from Scene
Constructor Details
#initialize(window) ⇒ MainMenuScene
Returns a new instance of MainMenuScene.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/scene.rb', line 26 def initialize(window) super(window) @continue = Continue.new(150, 50, window) @new_game = NewGame.new(150, 100, window) @difficulty = Difficulty.new(150, 150, window) @high_score = HighScore.new(150, 200, window) @quit = Quit.new(150, 250, window) @menu_items = [@new_game, @difficulty, @high_score, @quit] @selected_item = 0 @menu_items[0].select end |
Instance Method Details
#add_continue ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/scene.rb', line 47 def add_continue if @menu_items.size == 5 @menu_items[@selected_item].unselect @selected_item = 0 else @menu_items[0].unselect @menu_items.prepend(@continue) end @menu_items[0].select end |
#button_down(id) ⇒ Object
66 67 68 69 70 71 72 73 74 75 |
# File 'lib/scene.rb', line 66 def (id) case id when Gosu::KB_DOWN down when Gosu::KB_UP up else @menu_items[@selected_item].(id) end end |
#difficulty ⇒ Object
43 44 45 |
# File 'lib/scene.rb', line 43 def difficulty @difficulty.difficulty end |
#down ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/scene.rb', line 81 def down @menu_items[@selected_item].unselect @selected_item = if @selected_item == @menu_items.size - 1 0 else @selected_item + 1 end @menu_items[@selected_item].select end |
#draw ⇒ Object
77 78 79 |
# File 'lib/scene.rb', line 77 def draw @menu_items.each(&:draw) end |
#remove_continue ⇒ Object
59 60 61 62 63 64 |
# File 'lib/scene.rb', line 59 def remove_continue @menu_items[0].unselect @menu_items.drop(1) @menu_items[0].select @selected_item = 0 end |
#up ⇒ Object
93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/scene.rb', line 93 def up @menu_items[@selected_item].unselect @selected_item = if @selected_item.zero? @menu_items.size - 1 else @selected_item - 1 end @menu_items[@selected_item].select end |