Sha256: 2ef7f8844a1938670f933432d6ba802a6fd60fd62c42a632302e7372690158f8

Contents?: true

Size: 335 Bytes

Versions: 12

Compression:

Stored size: 335 Bytes

Contents

# Use this if you need a closest targeting mechanism.
#
module Targeting
  
  module Closest extend Trait
    
    # Returns the closest target of all targets in the fire arc.
    #
    # TODO fire arc
    #
    def acquire *targets
      targets.sort_by { |target| (target.position - self.position).length }.first
    end
  end
  
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
gosu_extensions-0.3.8 lib/traits/targeting/closest.rb
gosu_extensions-0.3.7 lib/traits/targeting/closest.rb
gosu_extensions-0.3.6 lib/traits/targeting/closest.rb
gosu_extensions-0.3.5 lib/traits/targeting/closest.rb
gosu_extensions-0.3.4 lib/traits/targeting/closest.rb
gosu_extensions-0.3.3 lib/traits/targeting/closest.rb
gosu_extensions-0.3.2 lib/traits/targeting/closest.rb
gosu_extensions-0.3.1 lib/traits/targeting/closest.rb
gosu_extensions-0.3.0 lib/traits/targeting/closest.rb
gosu_extensions-0.2.9 lib/traits/targeting/closest.rb
gosu_extensions-0.2.8 lib/traits/targeting/closest.rb
gosu_extensions-0.2.7 lib/traits/targeting/closest.rb