I have a pygame program, and I want it to be fullscreen using
pygame.display.set_mode((width, height), pygame.FULLSCREEN)
.
I do not know the width and height (resolution) of the computer, so I want to be able to retrieve it on both macOS and Windows, using something like this for example:
import platform
pf = platform.platform().lower()
if pf.startswith("windows"):
# code here
else:
# code here
I tried this:
import pygame
pygame.init()
screen = pygame.display.set_mode((640, 480), pygame.FULLSCREEN)
running = True
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
pygame.quit()
The set_mode
can take a width and height of zero to force native resolution. So you can just do:
screen = pygame.display.set_mode((0, 0), pygame.FULLSCREEN)
Take a look at the docs here for more information: http://www.pygame.org/docs/ref/display.html#pygame.display.set_mode