Features
- Collisions only - no gravity, rigid body handling, or complex solvers
- Is data-oriented and functional
"Sweep" tests indicate at least 1 of the objects is moving. The number indicates how many objects are moving. e.g., box-box-sweep2 means we are comparing 2 aabbs, both of which are moving. "Overlap" tests don't take movement into account, and this is a static check to see if the 2 entities overlap. plural forms imply a collection. e.g., BoxSegmentsSweep1Indexed() checks one box segment against a set of line segments. If there is more than one collision, the closest collision is set in the hitInfo argument.
BoxBoxOverlap(boxA, boxB *AABB, hitInfo *HitInfo) bool// BoxBoxContain returns true if a fully contains b. BoxBoxContain(a, b *AABB) boolBoxBoxSweep1(staticBoxA, boxB *AABB, boxBVel v.Vec, hitInfo *HitInfo) bool BoxBoxSweep2(boxA, boxB *AABB, boxAVel, boxBVel v.Vec, hitInfo *HitInfo) boolCircleCircleSweep2(c1, c2 *Circle, c1Vel, c2Vel v.Vec) boolBoxOrientedBoxOverlap(a *AABB, b *OBB) boolBoxOrientedBoxSweep2(a *AABB, b *OBB, va v.Vec, vb v.Vec) boolBoxSegmentSweep1(line *Segment, box *AABB, delta v.Vec, hitInfo *HitInfo) boolBoxSegmentsSweep1Indexed(lines []*Segment, aabb *AABB, delta v.Vec, hitInfo *HitInfo) (index int)BoxPointOverlap(box *AABB, point v.Vec, hitInfo *HitInfo) boolBoxSegmentOverlap(box *AABB, start, delta, padding v.Vec, hitInfo *HitInfo) boolLineCircleOverlap(raySeg *Segment, circ *Circle, overlapSeg *Segment) boolSegmentCircleOverlap(seg *Segment, c *Circle) []v.VecBoxCircleSweep2(box *AABB, circle *Circle, boxVel, circleVel v.Vec) bool(c *TileCollider) Collide(box AABB, delta v.Vec, onCollide TileCollisionCallback) v.VecRayTilemapDDA(pos, dir v.Vec, length float64, tm [][]uint8, cellSize float64, h *HitInfo) (bool, image.Point) - Clone this repository
- In the terminal, change to the examples directory
cd examples - Run a folder with
go run ./foldername. Example:go run ./box_box_sweep1
Most of these collision checks were adapted from existing open source repos:
- github.com/mreinstein/collision-2d
- youtube.com/watch?v=NbSee-XM7WA - ray-tilemap (RayTilemapDDA)
- jonathanwhiting.com/tutorial/collision - box-tilemap (TileCollider)









