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

Re: [pygame] [Announce] Python bindings for the bitmask collision detection library



hi,

I'm in irc now putting bitmask into pygame.

illume is my nick.

Cheers,



On 5/6/07, Ulf Ekström <uekstrom@xxxxxxxxx> wrote:
Hi.

> Bitmask as a separate module is a good idea.  I think your pygame.mask
> is a good name.  Then we can provide some pygame.sprite mixins, or
> methods to help there.
>
> - pygame.mask module.
> - move docs from the source to .doc file.
> - some unittests in the test/ directory.

Ok, I can do this.

> - move your pygame example to examples/bitmask.py or maybe...
> bouncy_bitmask.py ?

Sure, no problem. I have not even looked at the pygame source tree, so
I don't know how you organize stuff. I will have a look.

> I'm not sure about a surface method.  It might simplify things for
> some people though.  However then it makes surface depend on the
> bitmask module (not necessarily bad).

It is more complicated, but I can imagine it makes it easier to use
for beginners. Anyway, I cannot really help with this part so I leave
it up to you guys.

> Has it been tested on big endian machines?  eg ppc macs?  It looks to
> have checks in there for 64bit machines - has it been tested on 64bit
> machines too?

Yes. The library is used in my game 'Airstrike', which has been tested
on a lot of platforms: sparc, ppc, i386 and even some old amiga
platform. So I think it works. I develop on ppc and i386.

> 'maskFromSurface' might be a constructor argument?  This would be so
> common, that we should do our own implementation.

Yes. It is also much faster in C than in Python. I can't really think
of a good set of arguments to the constructor that allows for either
(width,height) or a surface, though.

 Do you think it
> would be very different for different games?  eg, using different
> alpha levels as 'empty'.  5% alpha might be considered to be gone by
> some games/sprites.  If you think that's useful, an alpha_threshold
> argument might be appropriate.

I think it's a good idea. It can default to 50%.

> As you suggest, there's lots of other uses for bitmasks, other than collision.
>
> Blitting surfaces masked with a bitmask might be a future application.
>  Another future application might be to reduce over draw - by using
> the bitmask to show which pixels we have updated.
>
> A mask.setrange() method might be useful.  So you can set a range of
> bits at once, quickly.

Perhaps this can wait until the next release, I think collision
detection is the main feature, and it may seem overly complicated if
we add a lot of extra functions. But again, I think you can decide
this best.

I will start working on this and try to be on irc next wednesday.

Regards,
UIf