0

I am trying to rotate an image by a certain angle in python using the pygame module, but I don't know how to do so. Can anyone help me with this?

My code:

import pygame
pygame.init()
block = pygame.image.load('long.png')

screen = pygame.display.set_mode((1200, 800))

x = 400
y = 400

a = 45

def func(x, y, a):
    screen.blit(block, (x, y))
    #rotate the image by angle a.
    pygame.display.update()

running = True
while running:

    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            running = False

    func(x, y, a)

pygame.quit()
coder420
  • 163
  • 3
  • 8

1 Answers1

1

You can make use of pygame.transform.rotate(block ,a)