Search on blog:

PyGame: Transparent circle or other shape

python

pygame.draw.circle() and other method in pygame.draw don't use alpha channel to draw so you have to draw it on new Surface() (to get it as bitmap) and add alpha and colorkey to Surface() before you blit this surface to screen.

import pygame

pygame.init()

screen = pygame.display.set_mode((400, 300), 0, 32)

surface1 = pygame.Surface((100,100))
surface1.set_colorkey((0,0,0))  # use `(0,0,0)` (black color) as transparent color
surface1.set_alpha(128)  # transparency 50% for other colors
pygame.draw.circle(surface1, (0,255,0), (50,50), 50)

surface2 = pygame.Surface((100,100))
surface2.set_colorkey((0,0,0))  # use `(0,0,0)` (black color) as transparent color
surface2.set_alpha(128)  # transparency 50% for other colors
pygame.draw.circle(surface2, (255,0,0), (50,50), 50)

screen.blit(surface1, (125,100))
screen.blit(surface2, (175,100))

pygame.display.update()

running = True

while running:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            running = False

pygame.quit()
If you like it
Buy a Coffee