Class: GUI::LeaderBoard
- Inherits:
-
Object
- Object
- GUI::LeaderBoard
- Defined in:
- lib/GUI/gosu.rb
Instance Method Summary collapse
- #draw ⇒ Object
-
#initialize(window, robots, xres, yres, position = :right_top) ⇒ LeaderBoard
constructor
A new instance of LeaderBoard.
Constructor Details
#initialize(window, robots, xres, yres, position = :right_top) ⇒ LeaderBoard
Returns a new instance of LeaderBoard.
36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/GUI/gosu.rb', line 36 def initialize(window, robots, xres, yres, position = :right_top) @font_size = (xres / 45).to_i @position = position @robots = robots @font = Gosu::Font.new(window, BIG_FONT, @font_size) case position when :right_top @x_offset = xres-(@font_size * 9) when :left_top @x_offset = @font_size end @y_offset = @font_size * 2 end |
Instance Method Details
#draw ⇒ Object
50 51 52 53 54 55 56 57 58 |
# File 'lib/GUI/gosu.rb', line 50 def draw if @robots @robots.sort_by{|k,v| -k.energy}.each_with_index do |r, i| y = @y_offset + (i * (@font_size * 1.5).to_i) - (@font_size * 1.5).to_i @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 |