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

Re: [pygame] Re: manually cutting a picture



On, Tue Nov 06, 2007, Joseph king wrote:

> I have a kinda hard question.... i am trying to build a jigsaw game with
> python, i would like to give the option for people to create there own
> puzzle piece.... does anyone know how to accomplish this it is becoming
> increasingly difficult for me

Create a surface with the full image, then cut it into single pieces using
the Surface.blit() method with the area argument:

fullimage = pygame.image.load ("image.png")
piece1 = pygame.Surface ((50, 50))
piece1.blit (fullimage, (0, 0), (20, 20, 50, 50))

You now have blitted the fullimage area located at 20, 20 (from the
topleft) with a width and height of 50 to piece1.

Regards
Marcus

Attachment: pgpQlMzkbdN1R.pgp
Description: PGP signature