This site is no longer active and is available for archival purposes only. Registration and login is disabled.

pixel perfect collision detection?


pixel perfect collision detection?

Postby amdzero » Sep 30, 2004 @ 5:16am

User avatar
amdzero
pm Member
 
Posts: 13
Joined: Apr 5, 2004 @ 4:52pm


Postby Presto » Sep 30, 2004 @ 6:43pm

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
User avatar
Presto
pm Insider
 
Posts: 763
Joined: Jan 20, 2003 @ 5:51am
Location: Kalesian Archipelago


Postby amdzero » Sep 30, 2004 @ 10:38pm

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.
User avatar
amdzero
pm Member
 
Posts: 13
Joined: Apr 5, 2004 @ 4:52pm


Postby Presto » Oct 1, 2004 @ 1:19am

User avatar
Presto
pm Insider
 
Posts: 763
Joined: Jan 20, 2003 @ 5:51am
Location: Kalesian Archipelago


Postby amdzero » Oct 1, 2004 @ 2:23am

User avatar
amdzero
pm Member
 
Posts: 13
Joined: Apr 5, 2004 @ 4:52pm


Return to PocketFrog & PocketHAL


Sort


Forum Description

SDKs for fast and robust device-independent access to Pocket PC display hardware.

Moderators:

sponge, Kzinti

Forum permissions

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

cron