0
\$\begingroup\$

I always get the error message "video system not initialized"

I don't get where I went wrong with the code below:

import pygame
pygame.init()

display_width = 800
display_height = 600

gameDisplay = pygame.display.set_mode((display_width, display_height))
pygame.display.set_caption('4 pics 1 word: ASTRONOMY VERSION')

black = (0,0,0)
white = (255,255,255)
red = (255,0,0)
green = (0,255,0)
blue = (0,0,255)

answered = False
satImg1 = pygame.image.load(r'C:\Users\andrea\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Python 3.7\img\satellite.png')

def satImg(x,y):
    gameDisplay.blit(satImg1,(x,y))

x = (display_width * 1.0)
y = (display_height * 1.5)

while not answered:
    if pygame.mixer.get_busy() != None:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                answered = True         
    gameDisplay.fill(white)
    satImg1 = (x, y)
    pygame.quit()
    quit()
\$\endgroup\$
  • \$\begingroup\$ When asking questions here, please take the time to ensure your code is formatted legibly and your issue is fully explained. Consult the help center if you have trouble with formatting. I've edited your question to clean it up, but it would still benefit from more text description of what you're trying to do, and how you've tried solving this problem so far. \$\endgroup\$ – DMGregory Feb 25 at 15:50
  • \$\begingroup\$ It seems to be a bad identation in the last lines, maybe quit() calls should be out of the while loop \$\endgroup\$ – Juanpa Mar 1 at 1:27
1
\$\begingroup\$

As Juanpa already implied in a comment, you get the error because you call the quit() function, which in turn makes the pygame module unusable, and your code should look like this:

...
while not answered:
    if pygame.mixer.get_busy() != None:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                answered = True         
    gameDisplay.fill(white)
    satImg1 = (x, y)
pygame.quit()
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.