1
作为pygame的新手,我在网上搜索了如何创建矩形。然后我使用该代码,但运行时只显示一个空白屏幕。没有显示错误代码,但代码没有像我想象的那样运行。我究竟做错了什么?使用Pygame创建矩形
import pygame, sys
import pygame.locals as GAME_GLOBALS
import pygame.event as GAME_EVENTS
pygame.init
#window variables
WindowHeight = 480
WindowWidth = 640
surface = pygame.display.set_mode((WindowWidth,WindowHeight))
surface.fill((255,255,255))
pygame.draw.rect(surface,(100,0,155),(0,0,100,100))
while True:
for event in GAME_EVENTS.get():
if event.type == GAME_GLOBALS.QUIT:
pygame.quit()
sys.exit()
你不*调用*'pygame.init'。 – jonrsharpe
窗口显示 –