I am making a game in Pygame and I want it so every time the sprite jumps it rotates mid-air and lands on its side. A lot like Geometry Dash jumping if you have ever played that. I have some code but it won't rotate.

This is my player class

class Player(pygame.sprite.Sprite):
    def __init__(self, color, x, y, width, height):
        self.color = color
        self.image = pygame.Surface([width, height])
        self.rect = self.image.get_rect()
        self.rect.x = x
        self.rect.y = y

and this is my code to rotate

while running:
    if keys[pygame.K_SPACE]:
            pygame.transform.rotate(player.image, 45)
            isjump = True    
            v = jump_v

You have to take the returning value of rotate :

player.image = pygame.transform.rotate(player.image, 45)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.