[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Bitmask Collision Response



One option I've been investigating is the use of convolutions for bitmask collision response. I've been using it for drag-and-drop collision response, but you might find it useful for other kinds of response as well.

The way it works is as follows: if I have an object that's moving through an environment, then convolving the object's mask with the environment's mask yields a mask with the corresponding bit set if placing the object at that location would cause a collision. For drag and drop I form the convolution, and then place the object at the closest point to the mouse that has the bit cleared.

You can take a look at some code at http://pen.svn.sourceforge.net/viewvc/pen/src/ (see drag.py, demos/dragdemo.py, and maskutils.c). unfortunately it's been bit-rotting for a bit, so it may not work out of the box.

Hope it helps!

--Mike

pymike wrote:
Howdy,

I'm currently working on a project that requires bitmask collisions. I know how to /detect/ collisions, but it's response that has me stumped. I've been googling, and all I can find is detection - nil on response. Can anyone help?

I fear I may have to resort to a physics engine, though I'd very much like to keep it pure pygame.

Ciaozorz

--
- pymike