0

The program should fully cover the screen with the background image. instead, it says that it is a type error.

screen = pygame.display.set_mode(size)   

TypeError: argument 1 must be a sequence of length 2, not 1

import pygame

pygame.init()
size = [600.450]
screen = pygame.display.set_mode(size)
pygame.display.set_caption("yy")

done = False
clock = pygame.time.Clock()
background = pygame.image.load('calmingBG.jpg').convert()

while not done:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            done = True

    screen.blit(background,[0,0])
    pygame.display.flip()
    clock.tick(60)

pygame.quit()
sloth
  • 99,095
  • 21
  • 171
  • 219
Nneoma
  • 11
  • 3

1 Answers1

1

The problem of your code is your size variable is set to the numeric value of 600.450. You should set the variable to [600, 450].

I would also recommend you to use the sys module when you quit the game loop. It would be something like this:

import sys
import pygame

# set variables

while not done:
    # game loop

pygame.quit()
sys.exit()
aqua959
  • 99
  • 1
  • 14
  • Thank you, the program runs now but it still won't display the image. it says: ```background = pygame.image.load('calmingBG.jpg').convert()``` pygame.error: Couldn't open calmingBG.jpg – Nneoma Sep 03 '19 at 23:03
  • @Nneoma please be more specific about this error. Is calmingBG.jpg in your working directory? Is it spelled correctly? thanks. – aqua959 Sep 03 '19 at 23:36
  • 1
    @aqua959 *"Couldn't open calmingBG.jpg"*, read [Cannot open image in pygame](https://stackoverflow.com/questions/57766969/cannot-open-image-in-pygame-on-android/57767162#57767162) – Rabbid76 Sep 04 '19 at 04:45