I have a list of PNGs that are 120px by 80px each. But my character in the PNG is really smaller, only occupying the middle. Is there a way to loop through all the elements and make it so that the border of these PNGs exactly fit the image? Kind of like a really tight picture frame.
I'll assume that the list actually contains pygame.Surface
s, so what you can do is use pygame.Surface.get_bounding_rect
to get the smallest rectangle required to fit all the data and then subsurface all the surfaces in that list, so basically you'd have this:
image_list = [...]
image_list = [image.subsurface(image.get_bounding_rect()) for image in image_list]