Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8488365
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T21:30:52+00:00 2026-06-10T21:30:52+00:00

I am using pygame and python for a project I am building, and I

  • 0

I am using pygame and python for a project I am building, and I am building a splashscreen for when the game first opens. I have a .png that I want to show for the splashscreen, and decided to fade it in and out from black. the best way I found to do this was by blitting the image with a set alpha. I made this code, but it runs really slowly (the program hangs for 30 seconds) and doesn’t give an alpha. Only displays the picture onscreen. What am i doing wrong?

screen = pygame.display.set_mode([1066,600])

#Drawable surface
background = pygame.Surface(screen.get_size())

#Used for converting color maps
background = background.convert()

#Splashscreen

#image fades in
for i in range (225):
    background.fill((0,0,0))
    image = pygame.image.load("logo.png")
    image.set_alpha(i)
    logoimage = screen.blit(image,(0,0))
    pygame.display.flip()

pygame.time.delay(2000)

#image fades out

#goes on to display main menu
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T21:30:54+00:00Added an answer on June 10, 2026 at 9:30 pm

    Another problem that you might be having (besides what monkey said) is that you might need to use surface.convert() which converts the image into a form where the alpha can be changed. You can do either of the following.

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

    or

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

    I have found that, although surface.convert_alpha() should do pretty much the same thing, it doesn’t usually work. Try this test code to check.

    import pygame, sys
    pygame.init()
    window=pygame.display.set_mode((1500, 800))
    background=pygame.Surface((window.get_rect().width, window.get_rect().height))
    background.fill((0, 0, 0))
    image=pygame.image.load('InsertImageHere.png')
    image=image.convert()
    image2=pygame.image.load('InsertImage2Here.png')
    image2=image2.convert_alpha()
    rect=image.get_rect()
    rect2=image2.get_rect()
    rect2.left=rect.width+1
    i=1
    while True:
        for event in pygame.event.get():
            if event.type==12:
                pygame.quit()
                sys.exit()
        image.set_alpha(i)
        image2.set_alpha(i)
        window.fill((255, 255, 255))
        window.blit(background, background.get_rect())
        window.blit(image, rect)
        window.blit(image2, rect2)
        pygame.time.delay(20)
        i+=1
        if i==255:
            i=1
        pygame.display.update()
    

    In my testings, image 1 faded in properly, but image 2 stayed dark the whole time. You should try it for yourself; your computer might work differently.

    If surface.convert_alpha() does work for you, you should use it, otherwise, do what I said before. This should solve your problem.

    You should also note that I used pygame.time.delay(20) rather than 2000 like you had before. 2000 would be a bit too long if you are increasing the alpha in incraments of one.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently trying to write a multiple-file Python (2.6.5) game using PyGame. The problem
I am working on a project in python using pygame and pyro. I can
I'm using Python 2.7 and Pygame 1.9.1 The fact that there are a few
I'm working on an adventure game in Python using Pygame. My main problem is
I wanted to compile my python program that uses pygame into an executable using
I have a couple of Python functions that I use to make game development
I'm writing a game using Python and PyGame. (This is perscribed in the assignment,
I'm currently making a game using python 2.7 and pygame 1.9. I store my
Hey, I'm using pyGame and I want to: A) make a function that returns
I've just implemented a very rudimentary game of tetris in python using pygame and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.