Overview
Did the bullet hit? Did the player land? Collision detection answered gaming’s fundamental questions—when objects occupy the same space. Simple boxes worked for most cases, but fighting games needed precision. Each method traded accuracy against CPU cost, and clever programmers chose wisely based on game requirements.
Fast facts
- Purpose: Detect object intersection.
- Trade-off: Accuracy vs performance.
- Methods: Bounding box, circle, pixel-perfect.
- Application: Every action game.
Bounding box collision
| Step | Process |
|---|
| 1 | Define rectangle around object |
| 2 | Check if rectangles overlap |
| 3 | Overlap = collision |
if (a.x < b.x + b.width &&
a.x + a.width > b.x &&
a.y < b.y + b.height &&
a.y + a.height > b.y)
// Collision!
Circle collision
| Step | Process |
|---|
| 1 | Define circle (centre + radius) |
| 2 | Calculate distance between centres |
| 3 | Distance < combined radii = collision |
Good for: Balls, spherical objects, approximate checks.
Pixel-perfect collision
| Step | Process |
|---|
| 1 | Check bounding box first |
| 2 | If overlap, check overlapping pixels |
| 3 | Both non-transparent = collision |
Expensive but precise.
Hardware-assisted (C64)
| Register | Function |
|---|
| $D01E | Sprite-sprite collision |
| $D01F | Sprite-background collision |
| Usage | Read to check collisions |
Tile-based collision
| Advantage | Detail |
|---|
| Grid lookup | Check tile at position |
| Tile properties | Solid, empty, hazard |
| Performance | Very fast |
| Limitation | Grid-aligned only |
Optimisation techniques
| Technique | Purpose |
|---|
| Broad phase | Quick rejection test |
| Spatial partitioning | Only check nearby objects |
| Bitmasks | Fast boolean operations |
| Frame skipping | Check every N frames |
Common issues
| Problem | Cause |
|---|
| Tunnelling | Fast objects skip through |
| False positives | Bounding box too large |
| False negatives | Check too infrequent |
See also