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

Re: [pygame] Rotate an image



And when you're done rotating, you can go to another image.  The
original, if the rotation returns to the original position, or an
intermediary position if the rotation isn't 360 degrees.

For example, if you had a space ship seen from above, you could have
graphics for different positions (up, down, left, right), you can use
rotating to switch from one to the other smoothly (up -> rotate ->
right).  When you're finished rotating, you just replace the image
with the "destination" image.

You could do this with 8-directions or more, depending on how smooth
you want your animation and how many degrees of freedom your object
needs to move in.


On Sat, 16 Oct 2004 21:48:51 -0700, Pete Shinners <pete@shinners.org> wrote:
> Marcos Prieto wrote:
> 
> 
> > I'm  trying to rotate an image in a pygame app using
> > pygame.transform.rotate, i know that's normal that the image grown in
> > each rotation but i dont know how to manage this, How can i get the
> > original size for the rotated image?
> 
> If you are going to be animating a rotation, it is best to always rotate
> from the original source image. The rotation is a slightly lossy
> transformation, so if you keep rotating the same image it will get
> pretty degraded.
> 
> Usually when you rotate you want to keep the center point pinned down. I
> always do this by getting the current center of the image (before
> rotation). Then after rotating adjusting the position so the center matches.
> 
> Check out the pygame Chimp example where this happens when you whack the
> monkey. Look for the spin method on the actual Chimp class.
> http://www.pygame.org/docs/tut/chimp/ChimpLineByLine.html
>