Code

Rotating a Surface in Pygame

You can use transform.rotate() to rotate a surface counterclockwise by a certain number of degrees. You pass in the surface you want to rotate and a float representing the angle, which will rotate the image counterclockwise by that amount. If you pass in a negative angle, however, it will rotate the surface clockwise. The function will return the rotated surface as a new surface object.

unrotatedSurface = pygame.surface(20, 20) rotatedSurface = pygame.transform.rotate(unrotatedSurface, 90) #rotate surface by 90 degrees clockwise

0

1

Updated 2021-08-16

Tags

Python Programming Language

Data Science