即使看起来正确,也无法创建曲面


self.image = pygame.Surface(
int(math.sqrt((end_pos[1] - start_pos[1])**2 +(end_pos[0] - start_pos[0])**2)),  width)

返回错误:

ValueError: size needs to be (int width, int height)

pygame.Surface构造函数的参数是一个元组,其大小为Surface(pygame.Surface((with, height))(:

self.image = pygame.Surface(int(math.sqrt((end_pos[1] - start_pos[1])**2 +(end_pos[0] - start_pos[0])**2)), width)

self.image = pygame.Surface(
(int(math.sqrt((end_pos[1] - start_pos[1])**2 +(end_pos[0] - start_pos[0])**2)),  width))

分别

value = int(math.sqrt((end_pos[1] - start_pos[1])**2 +(end_pos[0] - start_pos[0])**2))
self.image = pygame.Surface((value, width))

最新更新