Pygame programs hanging on exit

前端 未结 5 1455
野趣味
野趣味 2021-01-02 07:11

I\'m tinkering around with pygame right now, and it seems like all the little programs that I make with it hang when I try to close them.

Take the following code, fo

5条回答
  •  执笔经年
    2021-01-02 07:46

    'if event.type==QUIT' generates a syntax error. Should be == pygame.QUIT Also, the rest of the line is incorrect but I can't see how. There's a cleaner variant here:

        running = True
        while running:
           for event in pygame.event.get():
               if event.type == pygame.QUIT:
               running = False
        pygame.quit()
    

提交回复
热议问题