无法创建表面,即使它看起来是正确的

cannot create surface even though it seems correct

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

returns错误:

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