import pygame # importing the module WIDTH = 800 HEIGHT = 600 pygame.init() # initializing the module screen = pygame.display.set_mode((WIDTH, HEIGHT)) # making the window of size WIDTH and HEIGHT run = True # Game status -> game is running while run: #-> while the game is running pygame.time.delay(50) # run this loop after every 50 milliseconds for event in pygame.event.get(): # for each event occuring in the window if event.type == pygame.QUIT: # checking if the close button was pressed run = False # update game status to stop (not running) pygame.display.update() # update our window with all the changes that we have done pygame.quit() # close the window