class RTanque::Gui::DrawGroup

Public Class Methods

new(tick_group, &create_drawable) click to toggle source
# File lib/rtanque/gui/draw_group.rb, line 6
def initialize(tick_group, &create_drawable)
  @tick_group = tick_group
  @mapped_drawables = Hash.new do |h, tickable|
    h[tickable] = create_drawable.call(tickable)
  end
end

Public Instance Methods

draw() click to toggle source
# File lib/rtanque/gui/draw_group.rb, line 23
def draw
  self.each do |drawable|
    drawable.draw
  end
end
each(&block) click to toggle source
# File lib/rtanque/gui/draw_group.rb, line 13
def each(&block)
  @tick_group.each do |tickable|
    if tickable.dead?
      @mapped_drawables.delete(tickable)
    else
      block.call(@mapped_drawables[tickable]) # This invokes @mapped_drawables's block if tickable not already in the hash
    end
  end
end