[Python] The full screen in the pie game

Asked 2 years ago, Updated 2 years ago, 19 views

I'm not familiar with this because it's English even though I googled How do I get a full screen when I press a certain key in a pie game?

python

2022-09-21 11:49

2 Answers

You can change to full screen by invoking the following command:

pygame.display.set_mode(screensize, FULLSCREEN)

The entire code that applied it.

import pygame
from pygame.locals import *
import ctypes #To obtain resolution

surface = pygame.display.set_mode((500, 500))

while True:
    for event in pygame.event.get():
        if event.type == KEYDOWN:
            if event.key == order('f'): When you press #f
                user32 = ctypes.windll.user32
                screensize = user32.GetSystemMetrics(0), user32.GetSystemMetrics(1) #Discover the resolution
                surface = pygame.display.set_mode(screensize, FULLSCREEN) # Switch to full screen

    pygame.display.update()
    surface.fill((255, 255, 255))

I hope it was helpful!


2022-09-21 11:49

Insert the event code and switch to full screen when the event occurs.

Please refer to the link below.

https://www.pygame.org/wiki/toggle_fullscreen?parent=CookBook


2022-09-21 11:49

If you have any answers or tips


© 2025 OneMinuteCode. All rights reserved.