pygame how to rotate image properly?
In pygame I am unable to rotate an image/surface. The image is drawing properly just not rotating.
self.other1 = pygame.image.load("enemy.png").convert_alpha()
self.other2 = pygame.transform.rotate(self.other1, math.radians(270))
s开发者_C百科elf.screen.blit(self.other2, (0, 0))
What exactly am I doing wrong?
1.- Which version are you using (both pygame and python)?
2.- You don't need radians
3.- You must specify a problem your description seems ambiguous
Anyway I leave an example here. Good luck.
import pygame
from pygame.locals import *
SIZE = 640, 480
pygame.init()
screen = pygame.display.set_mode(SIZE)
done = False
screen.fill((0, 0, 0))
other1 = pygame.image.load("enemy.png").convert_alpha()
other2 = pygame.transform.rotate(other1, 270)
screen.blit(other2, (0, 0))
pygame.display.flip()
while not done:
for e in pygame.event.get():
if e.type == QUIT or (e.type == KEYDOWN and e.key == K_ESCAPE):
done = True
break
精彩评论