0

I am trying to import the image of a flappy bird, and even after .convert() or .convert_alpha() it's still not transparent? I flipped display right after converting, what am I missing?

import pygame
import os
from pipesforbird import Pipewall
pygame.init()
running = True

def player(x, y):
    playerimg = pygame.image.load('birdo.png').convert()
    screen.blit(playerimg, (x, y))
    pygame.display.flip()
    
x = 50
y = 50
heigth = 60
width = 40
vel = 1
GREEN = (20, 255, 140)
GREY = (210, 210 ,210)
WHITE = (255, 255, 255)
RED = (255, 0, 0)
PURPLE = (255, 0, 255)
YELLOW = (255, 255, 0)
CYAN = (0, 255, 255)
BLUE = (100, 100, 255)
BLACK = (0, 0, 0)
incomingpipes = pygame.sprite.Group()
greenPipewall = Pipewall(GREEN, 100, 300, 100)
greenPipewall.rect.x = 700
greenPipewall.rect.y = 0
secondPipewall2 = Pipewall(GREEN, 100, 400, -10)
secondPipewall2.rect.x = 1000
secondPipewall2.rect.y = 400
incomingpipes.add(greenPipewall)
incomingpipes.add(secondPipewall2)

while running:
    screen = pygame.display.set_mode((800, 800))
    screen.fill((0,0,0))
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            running = False
    y += vel
    keys = pygame.key.get_pressed()
    if keys[pygame.K_SPACE]:
        y -= (vel * 2)
    if keys[pygame.K_ESCAPE]:
        quit()
    if y <= 100:
        y = 100
    if y >= 605:
        y = 605
    for Pipewall in incomingpipes:
        Pipewall.moveLeft(vel)
        if Pipewall.rect.x < -100:
            Pipewall.rect.x = 800
    screen.fill(BLUE)
    incomingpipes.update()
    incomingpipes.draw(screen)
    pygame.draw.rect(screen, GREY, [0, 0, 800, 100], 0)
    pygame.draw.rect(screen, GREY, [0, 650, 800, 200], 0)
    player(x, y)
    pygame.display.flip()
    pygame.display.update()
quit()

this is the image in question (https://flyclipart.com/image-flappy-bird-png-767238)

  • Are you sure that the image has a transparent background? How did you download the image? You must use `convert_alpha()`. `convert()` turns the image in a nin-trnasparent image. – Rabbid76 Jun 27 '21 at 07:05
  • the site says it does, i'm going to try another image real quick, but convert_alpha() is on it as of current and it's operating with a checkered box around it still. every other question about this is five years old and pygame has been updated since then, so this is kind of confusing. – Dalton Donovan Jun 27 '21 at 07:07
  • You didn't download the image, but just a preview of the image. The background of the preview is not transparent but checkered – Rabbid76 Jun 27 '21 at 07:08
  • 1
    holy crap you're right. well, here's a monument to needing a break. thank you for your help – Dalton Donovan Jun 27 '21 at 07:14

0 Answers0