Pygame Fullscreen Mode Exit
Solution 1:
pygame.QUIT
is a constant value (an integer) that is used to check the type of an event. To uninitialize pygame, you have to call pygame.quit()
(lowercase), but that actually doesn't quit your game but only uninitializes the loaded pygame modules. I think it's only needed to close the window if you've started your game in a tkinter based editor like IDLE.
To quit a game you can just break out of the while loop and let Python end the program as usual, or you can call sys.exit()
.
Since you can't click on the 'x' button to close the window in fullscreen mode, you have to use a key like Esc.
running = Truewhile running:
foreventin pygame.event.get():
ifevent.type == pygame.QUIT:
running = False
elif event.type == pygame.KEYDOWN:
ifevent.key == pygame.K_ESCAPE:
running = False # Set running toFalsetoend the whileloop.
Solution 2:
There's a boolean, running
, that's not being used.
Instead of this:
running = TruewhileTrue:
foreventin pygame.event.get():
ifevent.type == pygame.QUIT:
pygame.QUIT()
...consider doing this:
running = Truewhile running:
foreventin pygame.event.get():
ifevent.type == pygame.QUIT:
running = False
Solution 3:
First off I assume that you are using Windows, and that the version is not Windows Vista or earlier. If you are using a macOS, then I can't help you.
If none of those work, and you do end up getting stuck and having to reboot your computer, then this will help you.
These commands work for me when I got stuck in fullscreen:
- Ctrl + Esc
- Just pressing the ⊞(window) key
These both do the same thing, it pushes the window that pygame is opened in all the way to the back, opening the windows sidebar and thus revealing the task bar. It won't actually stop running the program, so if you click on the logo that represents your output, it will just go back to being stuck in fullscreen.
Post a Comment for "Pygame Fullscreen Mode Exit"