0
import pygame
import pygame, sys

pygame.init()
screen = pygame.display.set_mode((576,1024))
clock = pygame.time.Clock()

bg_surface = pygame.image.load('background-day.png')

while True:
    for event in pygame.event.get():
       if event.type == pygame.QUIT:
            pygame.quit()
            sys.exit()

screen.blit(bg_surface (0,0))


pygame.display.update()
clock.tick(120)

When running the code only a black screen shows and I cannot see my surface.

It shows that the problem is that "This code is unreachable" under the screen.blit line

If anyone knows how to fix this it would really help, Thank you

Matt U
  • 4,970
  • 9
  • 28

1 Answers1

1

The screen.blit line, and the lines below it, are currently not contained in the while True:. You need to indent those lines once to place them inside the loop body.

That code is "unreachable" while outside of the loop because your code is looping infinitely (while True) and exiting when the pygame.QUIT event is found, thus the code beyond the loop body will never be executed.

Matt U
  • 4,970
  • 9
  • 28