pygame.display.set_mode() 到底做了什么? [英] What exactly does pygame.display.set_mode() do?

查看:93
本文介绍了pygame.display.set_mode() 到底做了什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近开始尝试使用 pygame python 库,我只是想看看我是否理解正确:

I've recently started to play around with the pygame python library and I just wanted to see if I was understanding something correctly:

下面是一些设置窗口的代码.在说:

The following is some code that sets up the window. In the line that says:

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

display 是指 pygame 内部的模块吗?set_mode 是该模块中的类的名称吗?这是正确的吗?

, does display refer to a module inside of pygame and is set_mode the name of a class in that module? Is this 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')

推荐答案

display 是一个模块,而 set_mode 是一个 function 在里面模块.它实际上创建了一个 pygame.Surface 类的实例,并返回它.请参阅文档.

display is a module, and set_mode is a function inside that module. It actually creates an instance of the pygame.Surface class, and returns that. See the docs.

在 Python 中,标准是类的名称大写,模块和函数都是小写的.并非所有事情都如此,但很多事情都是如此,看起来 pygame 就是其中之一.

In Python, the standard is that classes have capitalised names, and modules and functions are all lower case. Not everything follows that, but a lot of things do, and it looks like pygame is one of them.

这篇关于pygame.display.set_mode() 到底做了什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆