Okay so Im just trying to get it working with rotations first before scaling then once I nail that the rotozoom should be easy. For the life of me I cant seem to get it working. Heres a simple class that I want the object to rotate over time as well a transform in the x direction. The transform is working fine but i just cant get it to rotate.
class Puff(pygame.sprite.Sprite):
def __init__(self, screen):
pygame.sprite.Sprite.__init__(self)
self.screen = screen
try:
self.imagePuff = pygame.image.load(os.path.join("Images","puff.tga")).convert()
except:
raise UserWarning, "Unable to find Puff image"
self.imagePuff.set_colorkey((0,0,255))
self.image = self.imagePuff
self.rect = self.image.get_rect()
self.x = self.screen.get_width()/3
self.y = self.screen.get_height()/3+10
self.rect.center = (self.x, self.y)
self.lifespan = 60
self.speed = 1
self.count = 0
self.angle = 0
def update(self):
self.calcPos()
self.rect.center = self.x, self.y
self.transform()
if self.count > self.lifespan:
self.kill()
def calcPos(self):
self.x -= 5
self.y = self.y
def transform(self):
self.count += 1.1
self.angle += self.count*25
self.newTrans = pygame.transform.scale(self.copyImage, (400,400))
self.newRect = self.newTrans.get_rect()
self.newRect.center = self.rect.center
This is how I've made it so you can rotate your puff class:
Essentially the key points are:
In the update method, and the two methods for changing the angle:
In the code above every clock tick the sprite is rotated to the right:
As you omitted your transform method, I had to edit the code to show how to do just rotations.
Hope this helps and if you need any more help please leave a comment.
Edit:
if you want to rotate and move to the left then you only really need to add this:
You should check out:
http://www.gamedev.net/topic/444490-pygame-easy-as-py/
If you search for "rotate.py" you'll see the a section of code on rotating sprites
EDIT:
Try changing you transform method to: