我正在尝试使用pygame旋转图像。这是我到目前为止的代码:
def main(self):
self.size = width, height = 500, 500
self.black = 0,0,0
self.screen = pygame.display.set_mode(self.size)
self.ball = pygame.image.load("deathstar.png")
self.ballrect = self.ball.get_rect()
self.ballcenter = self.ballrect.center
while 1:
for event in pygame.event.get():
if event.type == pygame.QUIT:
sys.exit()
elif event.type == pygame.MOUSEMOTION:
print ("mouse at ", event.pos)
self.rotate_image(some angle)
self.screen.fill(self.black)
self.screen.blit(self.ball, self.ballrect)
pygame.display.flip()
def rotate_image(self, angle):
我如何定义rotate_image?我需要根据鼠标放在屏幕上的位置进行旋转。谢谢!