Dariusz Krynicki
Dariusz Krynicki

Reputation: 2718

Game and blitted images are no transparent

I have a problem with no transparent png images in my pygame game.

I load png images and blit them to the screen. I have a dark background of game screen and white background of images. Although, the images blitted are visible with white background. I would expect images to be transparent however I can not achieve it.

I can not find an accurate information in internet with a solution to my problem.

Is there any chance somebody could point me into the right direction and review my game ? How to achieve transparency of images ?

Link to the python code and images: https://www.dropbox.com/s/ng99rqg4ur76msp/game.7z?dl=0

Pictures which shows my problem: Picture1

Game background color: black. Image backgroud color: white. How to get the image background transparent so it is not visible regardless the game background color ?

Upvotes: 0

Views: 650

Answers (1)

Keltusamor
Keltusamor

Reputation: 36

I don't understand your question but if your image has a transparent background you just use

image = pygame.image.load("image.png").convert_alpha()

If it has a white background you probably want to set the colorkey like

image = pygame.image.load("image.png").convert()

image.set_colorkey((255,255,255))

Upvotes: 2

Related Questions