gpt4 book ai didi

python - 使用pygame旋转图像

转载 作者:太空狗 更新时间:2023-10-29 21:26:48 27 4
gpt4 key购买 nike

我是 pygame 的新手,想编写一些代码,每 10 秒将图像简单地旋转 90 度。我的代码如下所示:

    import pygame
import time
from pygame.locals import *
pygame.init()
display_surf = pygame.display.set_mode((1200, 1200))
image_surf = pygame.image.load("/home/tempuser/Pictures/desktop.png").convert()
imagerect = image_surf.get_rect()
display_surf.blit(image_surf,(640, 480))
pygame.display.flip()
start = time.time()
new = time.time()
while True:
end = time.time()
if end - start > 30:
break
elif end - new > 10:
print "rotating"
new = time.time()
pygame.transform.rotate(image_surf,90)
pygame.display.flip()

此代码无效,即图像没有旋转,尽管“旋转”每 10 秒在终端中打印一次。有人可以告诉我我做错了什么吗?

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com