Sha256: e889725c56c29ebe9b92995424a31a9ab11f65c2ff253ec185a3dce3a6d8ac49

Contents?: true

Size: 598 Bytes

Versions: 13

Compression:

Stored size: 598 Bytes

Contents

# TODO optimize
#
class Moveables
  
  def initialize elements = []
    @elements = elements
  end
  
  delegate :each, :to => :@elements
  
  def register moveable
    @elements << moveable
  end
  def registered? moveable
    @elements.include? moveable
  end
  def remove shape
    @elements.delete_if { |element| element.shape == shape }
  end
  
  def draw
    @elements.each &:draw
  end
  def move
    @elements.each &:move
  end
  def targeting
    @elements.select { |m| m.respond_to? :target }.each do |gun|
      gun.target *@elements.select { |m| m.kind_of? Enemy }
    end
  end
  
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
gosu_extensions-0.2.6 lib/core/moveables.rb
gosu_extensions-0.2.5 lib/core/moveables.rb
gosu_extensions-0.2.4 lib/core/moveables.rb
gosu_extensions-0.2.3 lib/core/moveables.rb
gosu_extensions-0.2.2 lib/core/moveables.rb
gosu_extensions-0.2.1 lib/core/moveables.rb
gosu_extensions-0.2.0 lib/core/moveables.rb
gosu_extensions-0.1.28 lib/core/moveables.rb
gosu_extensions-0.1.27 lib/core/moveables.rb
gosu_extensions-0.1.26 lib/core/moveables.rb
gosu_extensions-0.1.25 lib/core/moveables.rb
gosu_extensions-0.1.24 lib/core/moveables.rb
gosu_extensions-0.1.23 lib/core/moveables.rb