Learn Before
  • Transform Operations in Pygame

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

4 years ago

Tags

Python Programming Language

Data Science

Related
  • Scale a Surface in Pygame

  • Flipping a Surface in Pygame

  • Rotating a Surface in Pygame

  • Scaling and Rotating a Surface in Pygame