Re: [pygame] Masks?

2009-12-18 Thread B W
Try http://www.pygame.org/wiki/FastPixelPerfect?parent=CookBook

Use the utilities to generate a mask that corresponds to each image
(frame). When you swap an image into the sprite object, also swap in
its mask. Then when you test the collision your masks will be used.

Gumm

On Tue, Dec 15, 2009 at 12:39 PM, Michael George
 wrote:
> I would create separate surfaces and masks for each frame.  If you want to
> keep all the frames in one surface, you can use subsurfaces for each frame:
> http://www.pygame.org/docs/ref/surface.html#Surface.subsurface.
>
> Then create the masks out of the subsurfaces and use Mask.overlap to do the
> intersection testing.
>
> --Mike
>
> inigo delgado wrote:
>>
>> Hi all:
>>
>> I don't have clear how to use the masks to collisions
>>
>> I have a bmps with a keycolor and with many frames of the same
>> spaceship in each and blit a area of them to simulate movement
>>
>> How can I do a mask of one part -a frame- of the bmp to see if it
>> collides with another part -another frame- of another bmp? To find a
>> exact collision of both? I've done collisions with rectangles, but I
>> wanna put big ships (like level bosses or medium size ships) and in
>> that ships this aproximation is poor, so I want, if is a rectangle
>> collition, to have the posibility of know if its a real collision
>>
>> If I do a mask of the bmps, I understand that then pygame will test
>> all the frames in each bmp with all frames of the other bmp?...?¿
>>
>>
>
>


Re: [pygame] Masks?

2009-12-15 Thread Michael George
I would create separate surfaces and masks for each frame.  If you want 
to keep all the frames in one surface, you can use subsurfaces for each 
frame: http://www.pygame.org/docs/ref/surface.html#Surface.subsurface.


Then create the masks out of the subsurfaces and use Mask.overlap to do 
the intersection testing.


--Mike

inigo delgado wrote:

Hi all:

I don't have clear how to use the masks to collisions

I have a bmps with a keycolor and with many frames of the same
spaceship in each and blit a area of them to simulate movement

How can I do a mask of one part -a frame- of the bmp to see if it
collides with another part -another frame- of another bmp? To find a
exact collision of both? I've done collisions with rectangles, but I
wanna put big ships (like level bosses or medium size ships) and in
that ships this aproximation is poor, so I want, if is a rectangle
collition, to have the posibility of know if its a real collision

If I do a mask of the bmps, I understand that then pygame will test
all the frames in each bmp with all frames of the other bmp?...?¿