Yubin Lee
Yubin Lee

Reputation: 882

Pygame rect object rotation

I am using python 2.7.9 and pygame 1.9.2. Here is the relevant code:

#!/usr/bin/python

import pygame, sys
from math import *
from decimal import *

while 1:
    ...
    deg = (atan2(Decimal(y), Decimal(x)))*180/pi
    pygame.transform.rotate(surf, deg)
    pygame.display.flip()
    screen.fill((0, 0, 0))
    print deg
    clock.tick(60)

Why isn't pygame.transform.rotate working? Printing the angle using math.acos has no problem, but I just can't seem to figure out how to rotate the rect object. I tried taking out *180/pi to use radians, but that didn't work. What am I doing wrong?

Upvotes: 0

Views: 638

Answers (1)

xnx
xnx

Reputation: 25508

I think you need:

surf = pygame.transform.rotate(surf, deg)

The pygame.transform.rotate method seems to return a rotated object rather than rotating its coordinates in place.

Upvotes: 1

Related Questions