class Menu
Public Class Methods
new(name, window, font, *choices)
click to toggle source
# File lib/game_2d/menu.rb, line 5 def initialize(name, window, font, *choices) @name, @window, @font, @choices = name, window, font, choices @main_color, @select_color = Gosu::Color::YELLOW, Gosu::Color::CYAN @right = window.width - 1 @choices.each_with_index do |choice, num| choice.x = @right choice.y = (num + 2) * @font.height end end
Public Instance Methods
draw()
click to toggle source
# File lib/game_2d/menu.rb, line 16 def draw str = to_s @font.draw_rel(str, @window.width - 1, 0, ZOrder::Text, 1.0, 0.0, 1.0, 1.0, @main_color) x1, x2, y, c = @right - @font.text_width(str), @right, @font.height, @main_color @window.draw_box_at(x1, y, x2, y+1, @main_color) @choices.each(&:draw) end
handle_click()
click to toggle source
to_s()
click to toggle source
# File lib/game_2d/menu.rb, line 32 def to_s @name.respond_to?(:call) ? @name.call(self) : @name.to_s end