问题描述
我正在学习如何构建 Python 游戏,并正在学习如何编写一个简单的 pygame 在线教程,不幸的是,我被停在了一个看似非常基本的部分.该教程已经很旧了,因此我很快就会得到答案的可能性很小,我已经尝试查找了该教程,但找不到具有类似问题的教程.该代码在没有颜色输入的情况下工作正常 GameDisplay.fill(white)
I'm learning how to build python games and was following a tutorial online how to program a simple pygame, unfortunately I was stopped at what seems like a very basic part. The tutorial is pretty old so the likely-hood that I will get an answer back soon is slim and I've tried looking this up but I can't find one with a similar issue. The code works fine without the color input GameDisplay.fill(white)
我正在运行 mac 版本 10.11,并使用 python 2.7.10 为 pygame 编码.我在 python shell 上没有得到回溯错误,我只是得到一个Python 意外退出"并想知道我是否遗漏了一个重要的 Python 输入?
I'm running off a mac version 10.11, and coding with python 2.7.10 for pygame. I get no traceback error on the python shell, I just get a "Python quit unexpectedly" and wonder if I'm missing an important Python input?
import pygame
pygame.init()
GameDisplay = pygame.display.set_mode((800, 600))
pygame.display.set_caption("This Thing")
white = (255,255,255)
GameQuit = False
while not GameQuit:
for event in pygame.event.get():
if event.type == pygame.QUIT:
GameQuit = True
GameDisplay.fill(white)
pygame.display.update()
pygame.quit()
quit()
推荐答案
我已经在使用 python 2.7.10 的 windows 10 和使用 python 2.7.9 的 mac 10.10 上尝试了此代码(不完全相同,但接近).这些都不会复制相同的行为.尝试卸载并重新安装 pygame.
I have tried this code on both windows 10 with python 2.7.10 and mac 10.10 with python 2.7.9 (not exactly the same, but close). Neither of these would replicate the same behavior. Try uninstalling and reinstalling pygame.
这篇关于(pygame) 在插入颜色代码时意外崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!