The game freezes instead of quitting. I have to exit from Idle. Any ideas on what to do?
def quit_game():
for event in pygame.event.get():
if event.type == pygame.QUIT:
sys.exit()
quit_game()
The game freezes instead of quitting. I have to exit from Idle. Any ideas on what to do?
def quit_game():
for event in pygame.event.get():
if event.type == pygame.QUIT:
sys.exit()
quit_game()
This is an IDLE bug. I would recommend using a real IDE such as pycharm. However to fix this issue, have a look at the pygame FAQ. They offer this solution:
# ... running = True
while running:
event = pygame.event.wait ()
if event.type == pygame.QUIT:
running = False # Be IDLE friendly
pygame.quit ()
It may work....
def quit_game():
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
quit_game()