Why am I not getting appropriate values for the outline I am creating - mask with pygame

Viewed 39

I want to create an outline for a certain object - get a list of values (Tuple) corresponding to the outline according to the position of the object.

I get a list but it doesn't match the position of the object and I have to do another calculation to get the values contained on the list.

self.pos = (random.randint(10, WIDTH - 50), random.randint(10, HEIGHT - 50))
self.mask = pygame.mask.from_surface(self.img).outline()

this is the list I get: (It does not match the location of the object)

[(4, 2), (5, 2), (6, 2), (7, 2), (8, 2), (9, 2), (10, 2), (11, 2), (12, 2), (13, 2), (14, 2), (15, 2), (16, 2), (17, 2), (17, 3), (18, 4), (19, 5), (19, 6), (19, 7), (19, 8), (19, 9), (19, 10), (19, 11), (19, 12), (19, 13), (19, 14), (19, 15), (19, 16), (19, 17), (19, 18), (19, 19), (18, 19), (17, 20), (16, 20), (15, 20), (14, 20), (13, 20), (12, 20), (11, 20), (10, 20), (9, 20), (8, 20), (7, 20), (6, 20), (5, 20), (4, 20), (3, 19), (2, 19), (2, 18), (2, 17), (2, 16), (2, 15), (2, 14), (2, 13), (2, 12), (2, 11), (2, 10), (2, 9), (2, 8), (2, 7), (2, 6), (2, 5), (3, 4), (4, 3), (4, 2)]

and this is the code I use to fix it but I would love to get rid of it:

self.t = []
for i in range(len(self.mask)):
    self.t.append((self.pos[0] + self.mask[i][0], self.pos[1] + self.mask[i][1]))
0 Answers
Related