Class: DXOpal::Sprite::CollisionArea::Triangle
- Defined in:
- lib/dxopal/sprite/collision_area.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #absolute_poss ⇒ Object
- #collides?(other) ⇒ Boolean
-
#initialize(sprite, x1, y1, x2, y2, x3, y3) ⇒ Triangle
constructor
A new instance of Triangle.
- #type ⇒ Object
Methods inherited from Base
#aabb, #absolute, #absolute1, #transback, #transback1
Constructor Details
#initialize(sprite, x1, y1, x2, y2, x3, y3) ⇒ Triangle
Returns a new instance of Triangle.
261 262 263 264 265 |
# File 'lib/dxopal/sprite/collision_area.rb', line 261 def initialize(sprite, x1, y1, x2, y2, x3, y3) @sprite = sprite @poss = [[x1, y1], [x2, y2], [x3, y3]] super() end |
Instance Method Details
#absolute_poss ⇒ Object
282 283 284 |
# File 'lib/dxopal/sprite/collision_area.rb', line 282 def absolute_poss absolute(@poss) end |
#collides?(other) ⇒ Boolean
269 270 271 272 273 274 275 276 277 278 279 280 |
# File 'lib/dxopal/sprite/collision_area.rb', line 269 def collides?(other) case other.type when :Point, :Circle, :Rect other.collides?(self) when :Triangle (ox1, oy1), (ox2, oy2), (ox3, oy3) = *self.absolute_poss (dx1, dy1), (dx2, dy2), (dx3, dy3) = *other.absolute_poss `Opal.DXOpal.CCk.check_triangle_triangle(ox1, oy1, ox2, oy2, ox3, oy3, dx1, dy1, dx2, dy2, dx3, dy3)` else raise end end |
#type ⇒ Object
267 |
# File 'lib/dxopal/sprite/collision_area.rb', line 267 def type; :Triangle; end |