Documentation ¶
Index ¶
- func HitTestCircle(x, y float64, circle geom.Circle) bool
- func HitTestEllipse(x, y float64, ellipse geom.Ellipse) bool
- func HitTestPolygon(x, y float64, vertices []geom.Point) (hit bool)
- func HitTestRect(x, y float64, rect geom.Rect) bool
- func ResolveCollidingCircles(a, b *geom.Circle) bool
- func ResolveCollidingEllipses(a, b *geom.Ellipse) bool
- func ResolveCollidingPolygons(a, b *geom.Polygon) bool
- func ResolveCollidingRects(a, b *geom.Rect) bool
- type AABB
- func (b AABB) Center() geom.Point
- func (b AABB) GetX() float64
- func (b AABB) GetY() float64
- func (b AABB) Height() float64
- func (b AABB) HitTest(x, y float64) bool
- func (b AABB) HitTestXY(xy geom.XYGetter) bool
- func (b AABB) Intersects(target AABB) bool
- func (b AABB) Rect() *sdl.Rect
- func (b AABB) Union(target AABB) AABB
- func (b AABB) Width() float64
- type CircleCollider
- type Collider
- type EllipseCollider
- type HitTester
- type PolygonCollider
- type RectCollider
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ResolveCollidingCircles ¶
func ResolveCollidingRects ¶
Types ¶
type AABB ¶
AABB is an axis-aligned bounding box with X and Y indicating its top left corner.
func BoundsFromCenterSize ¶
func (AABB) Intersects ¶
type CircleCollider ¶
type CircleCollider struct {
// contains filtered or unexported fields
}
func (*CircleCollider) Bounds ¶
func (cc *CircleCollider) Bounds() AABB
func (*CircleCollider) HitTest ¶
func (cc *CircleCollider) HitTest(x, y float64) bool
HitTest returns true when position [x y] is inside the Circle. It calculates the squared distance between [x y] and the Circle's center X Y and compares this with the squared Radius.
func (*CircleCollider) HitTestXY ¶
func (cc *CircleCollider) HitTestXY(xy geom.XYGetter) bool
HitTestXY forwards the hit-test call to the geom.Circle HitTest method and returns true when the point [x y] is inside the collider.
func (*CircleCollider) Shape ¶
func (cc *CircleCollider) Shape() geom.Shape
type Collider ¶
func NewCollider ¶
type EllipseCollider ¶
type EllipseCollider struct {
// contains filtered or unexported fields
}
func (*EllipseCollider) Bounds ¶
func (ec *EllipseCollider) Bounds() AABB
func (*EllipseCollider) HitTest ¶
func (ec *EllipseCollider) HitTest(x, y float64) bool
HitTest returns true when position [x y] is inside the EllipseCollider's geom.Ellipse shape. https://math.stackexchange.com/questions/76457/check-if-a-point-is-within-an-ellipse
func (*EllipseCollider) HitTestXY ¶
func (ec *EllipseCollider) HitTestXY(xy geom.XYGetter) bool
HitTestXY returns true when the position of the XYGetter is inside Ellipse.
func (*EllipseCollider) Shape ¶
func (ec *EllipseCollider) Shape() geom.Shape
type PolygonCollider ¶
type PolygonCollider struct {
// contains filtered or unexported fields
}
func (*PolygonCollider) Bounds ¶
func (pc *PolygonCollider) Bounds() AABB
func (*PolygonCollider) HitTest ¶
func (pc *PolygonCollider) HitTest(x, y float64) (hit bool)
HitTest tests if the provided point [x y] is inside the PolygonCollider's geom.Polygon shape.
func (*PolygonCollider) HitTestXY ¶
func (pc *PolygonCollider) HitTestXY(xy geom.XYGetter) bool
HitTestXY forwards the hit-test call to the geom.polygon HitTest method and returns true when the point [x y] is inside the collider.
func (*PolygonCollider) Polygon ¶
func (pc *PolygonCollider) Polygon() geom.PolygonShape
func (*PolygonCollider) Shape ¶
func (pc *PolygonCollider) Shape() geom.Shape
type RectCollider ¶
type RectCollider struct {
// contains filtered or unexported fields
}
func (*RectCollider) Bounds ¶
func (rc *RectCollider) Bounds() AABB
func (*RectCollider) HitTest ¶
func (rc *RectCollider) HitTest(x, y float64) bool
HitTest returns true when the x and y values are within the Rect.
func (*RectCollider) HitTestXY ¶
func (rc *RectCollider) HitTestXY(xy geom.XYGetter) bool
HitTestXY forwards the hit-test call to the geom.Rect HitTest method and returns true when the point [x y] is inside the collider.
func (*RectCollider) Shape ¶
func (rc *RectCollider) Shape() geom.Shape