can you add a background in this code without errors?

You have to blit the background before drawing the scene, and you have to draw it in your game loop. When you draw a background, it covers everything that was previously drawn:

  1. Draw background
  2. Draw scene (all the objects)
  3. Update display

Note that there is no need to clear the background when you draw a background image. If the background image covers the entire window, there is no need to clear the background.


while running:
    # [...]

    while 1:
        for e in pygame.event.get():
            if e.type == QUIT:

        # [...]

        # draw background
        # screen.fill(0)  <--- superfluous
        screen.blit(BACKGROUND_FASE, (0, 0))

        # draw scene (objects)
        for i in range(len(images)):
            screen.blit(images[i], img_rects[i])

        # update display

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top