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

Re: [pygame] Rotation of image



On Sat, 2006-04-08 at 17:36 +0100, Tom Wardill wrote:
> I need the ship image to rotate so it always faces the centre.
> I've tried doing:
> self.image = pygame.transform.rotate(self.image, -dTheta)
> (where dTheta is the angle to rotate) but this destroys the image, and
> does some very strange things with the movement of the ship.

Rotation is a lossy transformation. To rotate an image once isn't too
bad, but multiple rotations will eventually chew up the original.

The solution you will want is to always hang onto the original and
rotate from that. You may look at pygame.transform for a more filtered
rotation.

self.totalRotate -= dTheta
self.image = pygame.transform.rotate(self.original, self.totalRotate)

If you are already framiliar with OpenGL in C, you can use the PyOpenGL
package that lets you do glRotate just like in C.