I'm not familiar with pygame, but likely it does not like the image being repeatedly rotated and blitted onto itself.
Check out if this answer on StackOverflow works for you.
Explanation
Rotating an image is inaccurate. Unless you rotate exactly by multiples of 90 degrees, you never get an exact pixel-to-pixel mapping. In other words, you loose a small amount of information when you rotate. Since you replace the original image with the rotated version, this information is lost forever. Thus, the effect gets worse the more you rotate.
You should never modify the original image. Instead, store the rotation angle in a variable, increase/decrease this angle when pressing left/right, and rotate by that angle.
Then, you can store the rotate image (rotatedSurf1
, rotatedRect1
) as a member variable and blit it to the screen when drawing the scene. Do not blit the rotated image back onto the original!
def turnLeft(self):
self.angle += 10
self.rotatedSurf = pygame.transform.rotate(self.image, self. angle)
self.rotatedRect = self.self.rotatedSurf.get_rect()
self.rotatedRect.center = (25, 25)
Don't forget to initalize self.angle to 0.
In the drawing function instead of doing something like display.blit(self.image)
, now do display.blit(self.rotatedSurf, rotatedRect)
.
self.image.blit(rotatedSurf1,rotatedRect1)
to something likeself.backgroundSurface.blit(rotatedSurf1,rotatedRect1)
. – Syntac_ Dec 18 '14 at 11:45