It closes on the x but not the escape key? Did you copy my code or did you type it in. Check for typos. Are you using an IDE? If so which IDE?
I think there were some issues with IDLE in which require sys.exit and pygame.quit such as
I think there were some issues with IDLE in which require sys.exit and pygame.quit such as
import pygame import sys screen = pygame.display.set_mode((800,600)) done = False while not done: for event in pygame.event.get(): if event.type == pygame.QUIT: done = True elif event.type == pygame.KEYDOWN: if event.key == pygame.K_ESCAPE: done = True screen.fill((255,255,255)) pygame.display.update() pygame.quit() sys.exit()
Recommended Tutorials: