【发布时间】:2019-04-01 20:40:00
【问题描述】:
我想看看一个大学项目的 pygame 模块。我找到了一个非常简短的教程,我按照该教程为游戏创建了一个窗口。
这是我的代码:
import sys
import pygame
from pygame.locals import *
pygame.init()
screen_width = 800
screen_height = 600
screen = pygame.display.set_mode(screen_width,screen_height)
pygame.display.set_caption("pygame test")
pygame.mouse.set_visible(True)
done = False
while not done:
for event in pygame.event.get():
if (event.type == KEYUP) or (event.type == KEYDOWN):
print(event)
if (event.key == K_ESCAPE):
done = True
如果我尝试执行应用程序,它会失败并出现以下错误:
screen=pygame.display.set_mode(screen_width,screen_height)
TypeError: must be 2-item sequence, not int
据我了解函数调用,它应该像我的示例一样工作。对在线错误的进一步研究并没有让我得到任何有用的结果。
我正在运行 OSX Mavericks、X11(或更好的 XQuartz)以及最新的 python 运行时和 pygame 所需的所有模块。
也许你可以帮助我。
【问题讨论】: