I'm working on a simple script to be used as a personal code skeleton for pygame projects (making this primarily for practice with Python, PyGame, and game design) but I'm running into an issue with automatically switching the display between fullscreen and windowed using f11. I'm reinitializing my pygame display appropriately on f11 being pressed and using a manual boolean variable "fullscreen" to keep track of whether display is fullscreen which is toggled after window is reinitialized. It works perfectly to switch between windowed and fullscreen, but the windowed display is not resizable, despite the RESIZABLE flag present when I initialize in windowed mode. Code below can be used to replicate the issue.
import sys
import pygame
# Initializations
pygame.init()
clock = pygame.time.Clock()
screen = pygame.display.set_mode((0, 0), pygame.FULLSCREEN)
fullscreen = False
# Game loop
while True:
for event in pygame.event.get():
# Handle quit via window or alt+f4
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
if event.type == pygame.KEYDOWN:
# Intended to re-initialize screen as windowed or fullscreen and toggle manual variable for tracking whether window is fullscreen
if event.key == pygame.K_F11:
if fullscreen:
# This code runs and initializes a 480p window, but it is not resizable
screen = pygame.display.set_mode((640, 480), pygame.RESIZABLE)
fullscreen = False
else:
screen = pygame.display.set_mode((0, 0), pygame.FULLSCREEN)
fullscreen = True
# El fin
pygame.display.update()
clock.tick(60)
```