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

Re: [pygame] XOR Animation



> Is there a way to do XOR Animation using pygame?  I only
> did a quick check but I couldn't find anything about this
> in either the pygame or SDL documentation.

no, not directly. i've heard the early-in-development
SDL2 will support different blitting mechanisms like
this, but currently you cannot.

the easiest way to do it in pygame would be to use
the surfarray module and Numeric python to xor. here's
an example...



#variables are sprite, sprite_pos, and screen

rect = sprite.get_rect().move(sprite_pos)

spritearray = pygame.surfarray.pixels2d(sprite)
screenarraybig = pygame.surfarray.pixels2d(screen)
screenarray = screenbigarray[rect.left:rect.right,
                             rect.top:rect.bottom]

screenarray ^= spritearray


tada, that will do it for you. assuming the sprite
and screen are any format except 24bit :]


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