pythonpython-3.xpygamefullscreenfullscreenchange

Reopening a game fullscreen is being broken in pygame


I am trying to make a 700x700 fullscreen game in pygame, but whenever I get out of the game and get back in, the screen breaks, showing what was opened before reopening the game. How do I fix it without changing the width and height of the screen?

Width, Height = 700, 700
win = pygame.display.set_mode((Width, Height), pygame.FULLSCREEN)

Solution

  • You will have to reset the fullscreen modifier whenever your window gets activated again. This might be a bug in a new version of pygame.

    You can detect when the game gets maximized with pygame.ACTIVEEVENT. You can put something like this in your event loop:

    if event.type == pygame.ACTIVEEVENT:
        if event.gain == 1:
            win = pygame.display.set_mode((Width, Height), pygame.FULLSCREEN)