Class: Leaderboard
- Inherits:
-
Object
- Object
- Leaderboard
- Defined in:
- lib/rrobots/gui/leaderboard.rb
Instance Method Summary collapse
- #draw ⇒ Object
-
#initialize(window, robots) ⇒ Leaderboard
constructor
A new instance of Leaderboard.
Constructor Details
#initialize(window, robots) ⇒ Leaderboard
Returns a new instance of Leaderboard.
2 3 4 5 6 7 8 |
# File 'lib/rrobots/gui/leaderboard.rb', line 2 def initialize(window, robots) @font_size = 24 @robots = robots @font = Gosu::Font.new(window, 'Courier New', @font_size) @x_offset = @font_size @y_offset = @font_size * 2 end |
Instance Method Details
#draw ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/rrobots/gui/leaderboard.rb', line 10 def draw if @robots @robots.each_with_index do |r, i| y = @y_offset + i * @font_size @font.draw("#{r.first.name}", @x_offset, y, ZOrder::UI, 1.0, 1.0, r.last.font_color) @font.draw("#{r.first.energy.to_i}", @x_offset + (@font_size * 6), y, ZOrder::UI, 1.0, 1.0, r.last.font_color) end end end |