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

[pygame] extending pygame masks



hello,

I've been working on some code that generates what I've been calling a "hitmask", namely a mask with the (x,y) bit set if placing one mask on another offset by (x,y) would cause a collision. It's part of a slick algorithm I'm working on for drag-and-drop collision response. I've implemented it in C against the bitmask api. I have n questions:

1. Is there any interest in putting this in pygame? I suspect no, because it's only useful for situations where you may freely drag oddly-shaped objects around but need to avoid collisions between them. It would be good for things like map editors. However if there is interest, I'd be happy to contribute it.

2. If not, I'd like to avoid shipping a modified pygame with my game. Is it possible for me to build and ship extensions that link against pygame internals (really just the bitmask stuff, and maybe rects at some point)? I haven't dug into the python/C boundary too much, although glancing over the pygame source it doesn't seem too bad. Can someone point me in the right direction?

3. If I do build my code separately, it currently looks impossible to actually get at the internals of a PyMaskObject without doing something hacky. In particular, the data structure and the PyMask_AsBitmap macro are only defined in mask.c, rather than in a separate header file. Is it reasonable for you to move that into pygame.h, or is it hidden for a reason?


...where n = 3.

Thanks!

--Mike