Pygame. display Surface quit?


#1

hey I'm making a simple pygame and can't understand why this part of my code is showing up as an error.

while not done:
screen.fill(black)
pygame.draw.ellipse(screen, colour, [x, y, width, height])
width += math.cos(count) * 10
x -= (math.cos(count) * 10) / 2
height += math.sin(count) * 10
y -= (math.sin(count) * 10) / 2
count += 0.5

specifically screen.fill(black) keeps coming back as error :display Surface quit.

any help would be much appreciated. thank you.


#2

the screen should default black background, did you init from pygame?


#3

yes I did. here's the full code.

import math
import pygame
pygame.init()

windowSize = [400, 300]
screen = pygame.display.set_mode(windowSize)
clock = pygame.time.Clock()

width = 200
height = 200
x = windowSize[0] / 2 - width / 2
y = windowSize[1] / 2 - height / 2
colour = pygame.color.Color('#57B0F6')
black = pygame.color.Color('#000000')

count = 0

done = False

while not done:
screen.fill(black)
pygame.draw.ellipse(screen, colour, [x, y, width, height])
width += math.cos(count) * 10
x -= (math.cos(count) * 10) / 2
height += math.sin(count) * 10
y -= (math.sin(count) * 10) / 2
count += 0.5

pygame.display.flip()

for event in pygame.event.get():
    if event.type == pygame.QUIT:
        done = True
clock.tick(24)
pygame.quit()

#4

set_mode takes an array? I thought it took a tuple.
I also thought fill took a tuple... it's been a while.

since your code isn't in the tickticktick code I can't for sure say if the formatting is correct.
My best recommendation would be double check whitespace and try subbing out windowSize = (400,300) instead of the array.

Ensure your pygame.quit is lined up to be even with your game loop.

while not done:
    code here

#indentation dictates this belongs to nothing
pygame.quit()

Sorry I couldn't be of more help.


#5

it was the indentation of pygame.quit()....... thanks a lot!


#6

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.