Page 1 of 1

pixel perfect collision detection?

PostPosted: Sep 30, 2004 @ 5:16am
by amdzero

PostPosted: Sep 30, 2004 @ 6:43pm
by Presto
This thread: http://www.pocketmatrix.com/forums/view ... c&start=15 has my collision detection code. The fundamentals of the two are almost identical, except I use GetColorMask to find the transparent color, in case it's not always 255,0,255.

It's scary to think I wrote that just over a year ago.

You might want to consider creating a "Pixel cColorMask = Color(255,0,255);" and use that instead in the comparisons. Then you won't be calling the Color(,,) function so much.

At the beginning you're adding the Widths and Heights of the surfaces to get the lower-right points, which isn't right. If a 5x5 surface is at 10,5, then its range goes from 10,5 to 14,9 (not 15,10). You need to subtract 1 from those calculations.

-John

PostPosted: Sep 30, 2004 @ 10:38pm
by amdzero
Thanks for the response I agree about the set mask I realized it this morning.

I have a question though, my math is a little off I think but if I test the small collision box with a < (less than) or > (greater than) then I don't have to subtract one right? what do you think?

btw your code looks much cleaner, I was looking for such a code for days.

PostPosted: Oct 1, 2004 @ 1:19am
by Presto

PostPosted: Oct 1, 2004 @ 2:23am
by amdzero