0

I recently just asked this question. I got my answer the only problem is the rotation is weird. It does not have one center point. The best way I can describe the rotation is the image pushed up to some left invisible wall, climbs up and then rotates until so other edge hits the invisible wall. I believe I need to set a constant center. How do I do this and where in my code do I put the center? I've looked at many examples but it seems like this weird rotation keeps occurring. Here is my code:

def update_angle(self):
    orig_car = self.car1
    loc = orig_car.get_rect().center
    car2 = pygame.transform.rotate(orig_car, self.angle)
    car2.get_rect().center = loc
    return car2
Community
  • 1
  • 1
JGerulskis
  • 800
  • 2
  • 10
  • 24
  • possible duplicate of [How do I rotate an image around its center using Pygame?](http://stackoverflow.com/questions/4183208/how-do-i-rotate-an-image-around-its-center-using-pygame) – Nick Fegley Feb 14 '15 at 17:26

1 Answers1

0

I had a similar problem to you, I managed to pull a small amount of code together to fix it. When you're blitting the car to the screen use this code:

rect = car2.get_rect(center=(200,200)) #Set the centre of rotation
SCREEN.blit(car2, rect)

It allows the image to rotate about a point, hope this helps!

George Willcox
  • 677
  • 12
  • 30