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

Re: [pygame] rotate sprites, newbie -.-



C.Schildt wrote:
Hello out there, i am a newbie with python so please do not hunt me down :)
I have a problem with rotating my sprite
The specific code element:
            self.image=pygame.transform.rotate(self.image,(self.angle))

Your problem is that you are rotating the same image many times. Rotating the image will make it a little larger, and also lower the quality. When you keep rotating it, it will grow and get a lot of ugly artifacts.

The solution is to keep a copy of the original image, and use that to rotate from each time. Here is an example...

            self.rotate += self.angle
            self.image = pygame.transform.rotate(
                        self.loaded_image, self.rotate)