Skip to content
Techniques & Technology

Collision Detection

When objects meet

Collision detection determined when game objects touched, using techniques from simple bounding boxes to pixel-perfect checks, each trading accuracy for performance.

C64NESAmigazx-spectrum programmingphysicstechnique 1975–present

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

StepProcess
1Define rectangle around object
2Check if rectangles overlap
3Overlap = 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

StepProcess
1Define circle (centre + radius)
2Calculate distance between centres
3Distance < combined radii = collision

Good for: Balls, spherical objects, approximate checks.

Pixel-perfect collision

StepProcess
1Check bounding box first
2If overlap, check overlapping pixels
3Both non-transparent = collision

Expensive but precise.

Hardware-assisted (C64)

RegisterFunction
$D01ESprite-sprite collision
$D01FSprite-background collision
UsageRead to check collisions

Tile-based collision

AdvantageDetail
Grid lookupCheck tile at position
Tile propertiesSolid, empty, hazard
PerformanceVery fast
LimitationGrid-aligned only

Optimisation techniques

TechniquePurpose
Broad phaseQuick rejection test
Spatial partitioningOnly check nearby objects
BitmasksFast boolean operations
Frame skippingCheck every N frames

Common issues

ProblemCause
TunnellingFast objects skip through
False positivesBounding box too large
False negativesCheck too infrequent

See also