[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [pygame] today's little update



----- Original Message ----- 
From: "Pete Shinners" <pete@visionart.com>
To: <pygame-users@seul.org>
Sent: Friday, January 26, 2001 3:45 AM
Subject: [pygame] today's little update


> btw, i've been chatting about pixel level collision routines,
> and the general consensus is they are just too slow. the best way
> to go about this type of collision is to just use a smaller rectangle
> to collide against, or breaking the sprite down into a few smaller
> rectangles. (as was suggested earlier)
> 


Hmmm. Slow? Depends on the application I guess. But if used cautiously it shouldn't be a problem. In my case, for example, I need to compare two players and some very small missile/bullet sprites with the background and the the same two players. A bitwise comparison need not occur if they don't overlap in a rectangle collision. And then it only needs to occur in the rect.clip() area between the two rectangles/sprites. Then assume that my sprites (or this clip area) are no more than 64 pixels wide (which they won't be) and 64 pixels high. This makes the comparison take 64 ands, and 64 shift. Possibly twice that because of spanning issues. It'll also take 64 more ands or 64 ifs, to check for the outcome of the ANDs. All this ofcourse assuming C/ASM level routines =)

I think I can safely do these at Python level. As long as the needs are as modest as mine. Should problems occur I can also go into the slightly hairier area of subdividing the masks into rectangular areas where collision shoud occur and then clip into those (now we could be talking really small pixel level and's). Small fry compared with what all these aplha blending what not operations should consume :-)


If my memory isn't letting me down I seem to remember having pixel level collision detection available to me on the lowly Amiga when programming AMOS basic (ohhh the horror). =)

-
Martin Sandin
come.to/vague



____________________________________
pygame mailing list
pygame-users@seul.org
http://pygame.seul.org