Why Pygame window closes instantly?

Viewed 58

I am trying to follow a pygame tutorial and the pygame window keeps closing instantly after opening. I have tried multiple different snippets of code from various places and none seem to keep the window open. i am using VScode if that makes a difference,

import pygame

pygame.init()

WIDTH, HEIGHT= 900,500
WIN=pygame.display.set_mode((WIDTH,HEIGHT))
pygame.display.set_caption("Rock Paper Scissors")


def main():
    gameRunning = True
    while gameRunning:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                print("QUIT")
                pygame.quit()
                gameRunning = False
                quit()
    
        WIN.fill(0,0,0)
        pygame.display.update()
    
if __name__=="__main__":
    main()
1 Answers

pygame.Surface.fill has just a single argument, which is either a RGB sequence, a RGBA sequence or a mapped color index. e.g. a tuple with the RGB color components:

WIN.fill(0,0,0)

WIN.fill( (0,0,0) )
Related