Documentation ¶
Overview ¶
Package collision provides struct for helping with positioning and collisions
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Circle ¶
Circle represents a 2d circle at Center with Radius
func (Circle) CollidesWithRect ¶ added in v0.1.3
CollidesWithRect compares a circle and a rect for collision
type Quadtree ¶
type Quadtree[R Rectangler] struct { // contains filtered or unexported fields }
Quadtree is a wrapper for quickly looking up possible collisions for it's element type R Because collision calculations are expensive to run, the quadtree looks for elements that are in the same quadrant to return a slice of possible collisions. Where further collision detection algorithms can be run.
func NewQuadtree ¶
func NewQuadtree[R Rectangler](bounds Rect) *Quadtree[R]
NewQuadTree creates a new QuadTree with element type R, number of levels, and the bounds of the 2D plane
func (*Quadtree[R]) Clear ¶
func (qt *Quadtree[R]) Clear()
Clear removes all elements from the QuadTree
func (*Quadtree[R]) Insert ¶
func (qt *Quadtree[R]) Insert(rect R)
Insert adds an element R to the internal objects slice. Checks to determine if a new quadrant needs to be formed.
func (*Quadtree[R]) Retrieve ¶
func (qt *Quadtree[R]) Retrieve(rect Rectangler) []R
Retrieve takes a Rectangler (not necessarily of type R of the QuadTree) and returns a slice of objects in the same quadrant
type Rect ¶
Rect represents a 2d rectangle at Origin with Width and Height
func (Rect) AlignedCollides ¶
AlignedCollides checks for collision between two Rects, that are aligned (i.e. neither of them rotated)
func (Rect) CollidesWithCircle ¶ added in v0.1.3
CollidesWithCircle checks a rectangle and a circle for collision
type Rectangler ¶
type Rectangler interface {
Rect() Rect
}
Rectangler is an interface that provides a Rect