Hi, I wrote some code using pygame that has two images. I am trying to figure out how transparency works, so I have tried to display a circle png on a square png. My code looks like this.
import pygame from pygame.locals import * #make window pygame.init() screen = pygame.display.set_mode((1270, 790), pygame.FULLSCREEN) pygame.display.set_caption('Pygame Caption') #load images backg = pygame.image.load('backg.png') circle = pygame.image.load('circle.png') #attempt to add transparency circle = circle.convert() circle = circle.convert_alpha() while True: #close program withescape key for event in pygame.event.get(): if (event.type == KEYDOWN): print event if (event.key == K_ESCAPE): done = True #blit image to screen screen.blit(backg, (0, 0)) screen.blit(cirlce, (100, 0)) #update screen pygame.display.update()
The color around the circle I am trying to display has a white background. I thought that
circle = cirlce.convert_alpha() was supposed to make all white backgrounds transparent, but i guess not or it's just an error in my code. Thanks in advance.