Class: MenuItem

Inherits:
Object
  • Object
show all
Defined in:
lib/menuitem.rb

Direct Known Subclasses

Continue, Difficulty, HighScore, NewGame, Quit

Instance Method Summary collapse

Constructor Details

#initialize(x, y, window) ⇒ MenuItem

Returns a new instance of MenuItem.



4
5
6
7
8
9
# File 'lib/menuitem.rb', line 4

def initialize(x, y, window)
  @x = x
  @y = y
  @window = window
  @selected = false
end

Instance Method Details

#button_down(id) ⇒ Object



11
12
13
# File 'lib/menuitem.rb', line 11

def button_down(id)
  on_enter if [Gosu::KB_ENTER, 40].include?(id) # 40 = big enter
end

#drawObject



25
26
27
# File 'lib/menuitem.rb', line 25

def draw
  @window.font.draw_text(@text.to_s, @x, @y, ZOrder::UI, 1.0, 1.0, @selected ? Gosu::Color::RED : Gosu::Color::YELLOW)
end

#on_enterObject



23
# File 'lib/menuitem.rb', line 23

def on_enter; end

#selectObject



19
20
21
# File 'lib/menuitem.rb', line 19

def select
  @selected = true
end

#unselectObject



15
16
17
# File 'lib/menuitem.rb', line 15

def unselect
  @selected = false
end