What exactly does pygame.display.set_mode () do?

I recently started playing with the python pygame library, and I just wanted to know if I understand something correctly:

Below is the code that sets the window. In a line that reads:

windowSurface = pygame.display.set_mode((WINDOWWIDTH, WINDOWHEIGHT), 0, 32)

displayrefers to a module inside pygame and is set_modethe class name in this module? Is it correct?

from pygame.locals import *

# set up pygame
pygame.init()

# set up the window
WINDOWWIDTH = 400
WINDOWHEIGHT = 400
windowSurface = pygame.display.set_mode((WINDOWWIDTH, WINDOWHEIGHT), 0, 32)
pygame.display.set_caption('Animation')
+3
source share
2 answers

displayis a module, and set_modeis a function inside this module. It actually creates an instance of the class pygame.Surfaceand returns it. See documents .

In Python, the standard is that classes have uppercase names, and modules and functions are lowercase. Not everything follows this, but much happens, and it looks like pygame is one of them.

+3

, display pygame, set_mode , , Surface, . .

0

All Articles