Sha256: b70c6b53bc9c62394b1a127cd6e2d614c76eeca140397b452030b98b1a551af7

Contents?: true

Size: 345 Bytes

Versions: 1

Compression:

Stored size: 345 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| distance = (target.position - self.position).length }.first
    end
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gosu_extensions-0.2.6 lib/traits/targeting/closest.rb