pygame.display.set_mode
时间: 2024-05-08 20:15:56 浏览: 130
pygame.display.set_mode() is a function in the Pygame library used to create a window or screen for displaying graphics. It takes in two arguments, a tuple representing the width and height of the screen and an optional argument that represents the type of display mode.
For example, to create a 800x600 window, you can use the following code:
```
import pygame
pygame.init()
screen_width = 800
screen_height = 600
screen = pygame.display.set_mode((screen_width, screen_height))
```
This will create a window of size 800x600 with default display mode. The display mode argument can be set to either FULLSCREEN, HWSURFACE, DOUBLEBUF or OPENGL to specify the type of display mode.
The function returns a Surface object that represents the screen or window that can be used for drawing graphics. The pygame.display.update() function can be used to update the screen with any changes made.
阅读全文