How to detect collisions between fast moving objects
Solution 1:
That's a generally a hard problem and for high-quality solution something like Box 2D library will be useful.
A quick and dirty solution (that gives false positives on diagonally moving objects) — check collision between bounding boxes that cover position of object in current and previous frame.
Instead of a.x
use min(a.x, a.x - a.velocity_x)
, instead of a.x + a.width
use max(a.x + a.width, a.x + a.width - a.velocity_x)
, etc.
If the object that is moving fast is small (a bullet), then test collision between line (from its origin to origin + velocity) and boxes of other objects.