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

returns the error:

ValueError: size needs to be (int width, int height)
martineau
  • 119,623
  • 25
  • 170
  • 301
aadnnn1
  • 53
  • 1
  • 4

1 Answers1

1

The argument to the constructor of pygame.Surface is a tuple with the size of the 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))

respectively

value = int(math.sqrt((end_pos[1] - start_pos[1])**2 +(end_pos[0] - start_pos[0])**2))
self.image = pygame.Surface((value, width))
Rabbid76
  • 202,892
  • 27
  • 131
  • 174