Class: DXOpal::Sprite::CollisionArea::Point
- Defined in:
- lib/dxopal/sprite/collision_area.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#absolute_pos ⇒ Object
Return [x, y].
- #collides?(other) ⇒ Boolean
-
#initialize(sprite, x, y) ⇒ Point
constructor
A new instance of Point.
- #type ⇒ Object
Methods inherited from Base
#aabb, #absolute, #absolute1, #transback, #transback1
Constructor Details
#initialize(sprite, x, y) ⇒ Point
Returns a new instance of Point.
89 90 91 92 |
# File 'lib/dxopal/sprite/collision_area.rb', line 89 def initialize(sprite, x, y) @sprite, @x, @y = sprite, x, y super() end |
Instance Method Details
#absolute_pos ⇒ Object
Return [x, y]
117 118 119 |
# File 'lib/dxopal/sprite/collision_area.rb', line 117 def absolute_pos absolute1([@x, @y]) end |
#collides?(other) ⇒ Boolean
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/dxopal/sprite/collision_area.rb', line 96 def collides?(other) case other.type when :Point self.absolute_pos == other.absolute_pos when :Circle x, y = *transback1(self.absolute_pos, other.sprite) cx, cy = *other.absolute_norot_pos `Opal.DXOpal.CCk.check_point_circle(x, y, cx, cy, #{other.r})` when :Rect x, y = *transback1(self.absolute_pos, other.sprite) ((x1, y1), (x2, y2)) = *other.absolute_norot_poss `Opal.DXOpal.CCk.check_point_straight_rect(x, y, x1, y1, x2, y2)` when :Triangle x, y = *absolute_pos (x1, y1), (x2, y2), (x3, y3) = *other.absolute_poss `Opal.DXOpal.CCk.check_point_triangle(x, y, x1, y1, x2, y2, x3, y3)` else raise end end |
#type ⇒ Object
94 |
# File 'lib/dxopal/sprite/collision_area.rb', line 94 def type; :Point; end |