Creating a rectangle from a mask in Pygame
08:52 18 Jun 2026

I'm a beginner in coding and I was wondering if it is possible to create a rectangle from a mask in Pygame. This is my code at the moment:

self.mask = pygame.mask.from_surface(self.image)
self.mask_rect = pygame.mask.Mask.get_rect(self.mask.get_size, position)

But I get this error message:

TypeError: descriptor 'get_rect' for 'pygame.mask.Mask' objects doesn't apply to a 'builtin_function_or_method' object

I'm not sure whether it is even possible to create a rectangle from a mask, but if it is does anyone have any advice on how to implement it?

python pygame