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

Re: [pygame] Pixel perfect collision detection...again



Hey John,

pixel perfect collision detection will be in the next release.

Using the modified code I posted in the other email, which was based
on yours.  Except the api is different so that it can work with
different methods later if wanted.

If anyone wants to do it before I get a chance go ahead!

What needs to be done:

1) Need to make new versions of array_colorkey, and array_alpha. The
need to output normal python arrays, not numeric ones.  There will
probably need to be a few changes needed to that C code.
2) The HitMask.collide(self, rect1, other_hitmask, rect2) method needs
to be coded in C.
3) An example/benchmark/unittest that tests the new collision detection.

The new functions should probably go in... src/pixelcollision.c ?


That's it!  All the other code is already written.


Or, for extra goodness you could use the bitmask library at: 
http://www.ifm.liu.se/~ulfek/projects/2d_Collision_Detection.html

However that could be added later if people need to make perpixel
collision detection faster.  The api I proposed can handle those
changes without any code changes to user code.


Cheers.



On 9/14/05, John Eriksson <john@xxxxxxxxxxxx> wrote:
> Hi all,
> There has been a realy intresting discussion about collision detection. But
> are any pygame developers interested in adding pixel perfect collision
> detection?
> 
> I can live with having to implement the pixel perfect detection each time I
> need it but it would be nice if it could be implemented in the core library.
> 
> So...PyGame developers...what do you say?
> 
> Best Regards
> /John Eriksson
> 
>