I have a rather confusing problem in running our game. I am trying to make a game using Python’s pygame and I am using images downloaded from the internet. The problem is that some images have a white background and some have a colored background. I used Photoshop to get rid of the white background and re-saved the image. However, when I ran the simulation in Python, it gave me the original picture with the original background. This is slightly perplexing to me.
Here’s the part of the code using pygame I used to implement the image:
self.image = pygame.image.load("jellyfishBad.png").convert()
self.image.set_colorkey(white)
self.rect = self.image.get_rect()
Thanks.
You need to use the .convert_alpha() method when loading the image for per pixel transparency.
So,