Class: Array

Inherits:
Object
  • Object
show all
Defined in:
lib/chingu/core_ext/array.rb

Direct Known Subclasses

Chingu::Rect

Instance Method Summary collapse

Instance Method Details

#each_bounding_box_collision(*args) ⇒ Object



25
26
27
28
29
30
31
32
33
34
# File 'lib/chingu/core_ext/array.rb', line 25

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



14
15
16
17
18
19
20
21
22
23
# File 'lib/chingu/core_ext/array.rb', line 14

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



3
4
5
6
7
8
9
10
11
12
# File 'lib/chingu/core_ext/array.rb', line 3

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