https://github.com/setanarut/coll
2d collision library for Go
https://github.com/setanarut/coll
2d-collision 2d-collision-checker 2d-collision-library aabb axis-aligned-bounding-box collision-detection collision-resolution dda-algorithm ebiten ebitengine game-development go golang golang-package intersection sat-solver sweep-line sweep-line-algorithm tilemap-collision
Last synced: 6 days ago
JSON representation
2d collision library for Go
- Host: GitHub
- URL: https://github.com/setanarut/coll
- Owner: setanarut
- License: mit
- Created: 2025-02-16T21:40:43.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2025-12-27T02:48:00.000Z (about 1 month ago)
- Last Synced: 2025-12-28T21:55:25.168Z (30 days ago)
- Topics: 2d-collision, 2d-collision-checker, 2d-collision-library, aabb, axis-aligned-bounding-box, collision-detection, collision-resolution, dda-algorithm, ebiten, ebitengine, game-development, go, golang, golang-package, intersection, sat-solver, sweep-line, sweep-line-algorithm, tilemap-collision
- Language: Go
- Homepage: https://pkg.go.dev/github.com/setanarut/coll
- Size: 135 KB
- Stars: 6
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://pkg.go.dev/github.com/setanarut/coll)
# coll - 2d collision library for Go
Features
* Collisions only - no gravity, rigid body handling, or complex solvers
* Is data-oriented and functional
## Conventions
"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 `h *Hit` argument.
## Visualization of some (but not all) functions
### Box-Box overlap

### Box-Box sweep 1

### Box-Box sweep 2

### Box-OrientedBox overlap

### Box-Segment sweep 1

### Box-Segments sweep 1 indexed

### Box-Segment overlap

### Line-Circle overlap

### Segment-Circle overlap

## Examples (Ebitengine)
1. Clone this repository
2. In the terminal, change to the examples directory `cd examples`
3. Run a folder with `go run ./foldername`. Example: `go run ./box_box_sweep1 `
## Credits
Most of these collision checks were adapted from existing open source repos:
* [github.com/mreinstein/collision-2d](https://github.com/mreinstein/collision-2d)
* [youtube.com/watch?v=NbSee-XM7WA](https://youtube.com/watch?v=NbSee-XM7WA) - ray-tilemap (RayTilemapDDA)
* [jonathanwhiting.com/tutorial/collision](https://jonathanwhiting.com/tutorial/collision) - box-tilemap (TileCollider)