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

Re: [pygame] [Pygame] Joystick Inputs



Nice catch, Ian.   I would never have thought of that.

On Wed, Dec 7, 2011 at 7:25 PM, Andrew Godfroy <killerrin@xxxxxxxxxxx> wrote:
Alright, Thank you for explaining it to me :) Now that I know whats happening I think I found a Solution. inside if my __init__ I added an extra variable “self.oldimage = self.image” Then inside of the rotateimage call, I have it set to: “self.image = pygame.transform.rotate (self.oldimage, -angle_degrees)”  This way, it will call up the oldimage, and save to the new surface.
 
Thank you for your help Ian
 
 
Sent: Wednesday, December 07, 2011 10:05 PM
Subject: Re: [pygame] [Pygame] Joystick Inputs
 
On Wed, Dec 7, 2011 at 7:51 PM, Andrew Godfroy <killerrin@xxxxxxxxxxx> wrote:
Alright, so If I’m getting you right, I should be using Rotozoom instead of just rotate, and build in a check to see if the previous angle is the same as the last one?
No.  Think about what's happening.  Try unrolling a couple calls:
self.image = pygame.transform.rotate(self.image, #something)
self.image = pygame.transform.rotate(self.image, #something)
self.image = pygame.transform.rotate(self.image, #something)
self.image = pygame.transform.rotate(self.image, #something)
. . . is equivalent to:
self.image = pygame.transform.rotate(pygame.transform.rotate(pygame.transform.rotate(pygame.transform.rotate(self.image, #something), #something), #something), #something)
Now do you see the problem?  Each image will be larger than the last.  Plus, you're doing a transformation repeatedly, which hurts image quality.
 
The attached image demonstrates what's happening.  You're starting with an image, then rotating, and then rotating THAT, and so on.  The image gets bigger and bigger.  I've drawn the padding as white and black, but they probably wouldn't necessarily be those colors.
 
Ian