简体   繁体   中英

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))
self.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    

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM