Mail Archives: djgpp/1997/02/07/15:55:42
On Wed, 5 Feb 1997 20:34:51 +0000, Shawn Hargreaves
<Shawn AT talula DOT demon DOT co DOT uk> wrote:
>>What is the best/fastest way to do collision detection routines for a
>>Action game in Allegro?
>
>If true pixel-perfect testing is needed, one of the fastest approaches
>is to pregenerate a monochrome mask for each sprite, containing one bits
>for the pixels that are set and zeros for the ones that aren't. To test
>two objects for a collision, line up these bitmasks depending on the
>relative positions of the sprites (this involves a lot of shifting and
>can be a big pain to get right), and then bitwise-or the two masks
>together. If the resulting value is non-zero, the objects have collided.
>This technique lets you check 32 pixels with each test, rather than
>having to laboriously loop through every single pixel in the sprite...
Surely you mean '...then bitwise-and the two masks together...'? A
bitwise-or will always be non-zero if either of the inputs is
non-zero...
George Foot
- Raw text -