Class: Array
- Inherits:
-
Object
- Object
- Array
- Defined in:
- lib/chingu/core_ext/array.rb
Direct Known Subclasses
Instance Method Summary collapse
- #each_bounding_box_collision(*args) ⇒ Object
- #each_bounding_circle_collision(*args) ⇒ Object
- #each_collision(*args) ⇒ Object
Instance Method Details
#each_bounding_box_collision(*args) ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/chingu/core_ext/array.rb', line 24 def each_bounding_box_collision(*args) list = (self + args).uniq collide_pair = [] list.each_with_index { |nr, i| self[i..size].collect { |nr2| collide_pair << [nr,nr2] } } collide_pair.each do |class1,class2| class1.each_bounding_box_collision(class2) do |object1, object2| yield object1, object2 end end end |
#each_bounding_circle_collision(*args) ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/chingu/core_ext/array.rb', line 13 def each_bounding_circle_collision(*args) list = (self + args).uniq collide_pair = [] list.each_with_index { |nr, i| self[i..size].collect { |nr2| collide_pair << [nr,nr2] } } collide_pair.each do |class1,class2| class1.each_bounding_circle_collision(class2) do |object1, object2| yield object1, object2 end end end |
#each_collision(*args) ⇒ Object
2 3 4 5 6 7 8 9 10 11 |
# File 'lib/chingu/core_ext/array.rb', line 2 def each_collision(*args) list = (self + args).uniq collide_pair = [] list.each_with_index { |nr, i| self[i..size].collect { |nr2| collide_pair << [nr,nr2] } } collide_pair.each do |class1,class2| class1.each_collision(class2) do |object1, object2| yield object1, object2 end end end |