我正在研究pygame,并且在绝大多数教程中都说应该在做任何事之前运行pygame.init().我正在做一个特定的教程,并按照一个人的方式键入代码,并注意到在示例之后,没有pygame.init(),也没有其他任何模块的显式初始化.
例如,以下工作(对我来说,至少)没有任何问题:
import pygame
screen = pygame.display.set_mode((600, 400))
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
raise SystemExit
只是想知道如何在运行pygame.init()时确切地找出初始化的内容以及未运行pygame.init()时初始化的内容.
最佳答案
This will attempt to initialize all the pygame modules for you. Not
all pygame modules need to be initialized, but this will automatically
initialize the ones that do.
http://www.pygame.org/docs/tut/ImportInit.html
我不知道必须初始化哪些模块,但看起来显示和事件不在该类别中.我只是建议你这样做,因为也许某些模块可以在不进行初始化的情况下工作,但不会以相同的方式工作,或者他们会错过重要的事情.