Class: Bomp::QuadTree
- Inherits:
-
ColliderSystem
- Object
- ColliderSystem
- Bomp::QuadTree
- Defined in:
- lib/bomp.rb
Defined Under Namespace
Classes: QuadNode
Instance Attribute Summary collapse
-
#child ⇒ Object
readonly
Returns the value of attribute child.
Attributes inherited from ColliderSystem
Instance Method Summary collapse
-
#initialize(width, height, **opts) ⇒ QuadTree
constructor
A new instance of QuadTree.
- #reload! ⇒ Object
- #restart! ⇒ Object
- #sort(group = nil, reload = true) ⇒ Object
Methods inherited from ColliderSystem
Constructor Details
Instance Attribute Details
#child ⇒ Object (readonly)
Returns the value of attribute child.
179 180 181 |
# File 'lib/bomp.rb', line 179 def child @child end |
Instance Method Details
#reload! ⇒ Object
197 198 199 200 |
# File 'lib/bomp.rb', line 197 def reload! @child&.clear @items.each { |item| @child.insert item } end |
#restart! ⇒ Object
202 203 204 205 |
# File 'lib/bomp.rb', line 202 def restart! clear! @child = QuadNode.new(0, 0, width, height, @opts) end |
#sort(group = nil, reload = true) ⇒ Object
187 188 189 190 191 192 193 194 195 |
# File 'lib/bomp.rb', line 187 def sort(group = nil, reload = true) reload! if reload if group.nil? @child.to_a else @child.group_by group end end |