delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/02/07/15:55:42

From: mert0407 AT sable DOT ox DOT ac DOT uk (George Foot)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Collison detection fo Action game
Date: Fri, 07 Feb 1997 11:21:41 GMT
Organization: Oxford University
Lines: 21
Message-ID: <32fb0fde.3669297@news.ox.ac.uk>
References: <855142026 DOT 12716 AT dejanews DOT com> <vgpI$hAr7O+yEwGt AT talula DOT demon DOT co DOT uk>
NNTP-Posting-Host: mc31.merton.ox.ac.uk
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019