[Solved] Not sure why If Statement is not working. (Pygame)

[ad_1]

Surfaces doesn’t have an object for retrieving the file name, but maybe you could use another variable to hold the file name?

#load images
bg_filename = "start.png"
background = pygame.image.load(bg_filename)

#keep looping through
while 1:
    #clear the screen before drawing it again
    screen.fill(0)
    #draw the screen elements
    screen.blit(background, (0,0))
    #update the screen
    pygame.display.flip()
    #loop through the events
    for event in pygame.event.get():
        if event.type == pygame.KEYDOWN:
            if event.key == pygame.K_e:
                if bg_filename == "start.png":
                    bg_filename = "new.png"
                    background = pygame.image.load(bg_filename)

0

[ad_2]

solved Not sure why If Statement is not working. (Pygame)