【发布时间】:2019-06-15 03:21:48
【问题描述】:
我正在 pygame 中制作游戏,我的朋友在尝试运行以下代码时遇到了以下问题。
import pygame
pygame.init()
screen = pygame.display.set_mode((640, 480))
pygame.display.set_caption('winter gam')
pygame.display.update()
running = True
clock = pygame.time.Clock()
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_ESCAPE:
running = False
clock.tick(60)
screen.fill((0, 0, 0))
pygame.draw.rect(screen, (255, 0, 0), [10, 10, 100, 100])
pygame.display.update()
pygame.quit()
我在我的 linux 发行版上运行了这段代码,但我的朋友正在运行 OSX 10.13.6,当他尝试运行它时遇到一个错误,说“非法指令:4”。
提供任何解决方案的唯一线程是这个:Illegal instruction: 4 on MacOS High Sierra
当我们将“pygame.init()”行更改为“pygame.font.init()”时,代码在他的机器和我的机器上都可以正常工作,这很奇怪,因为 pygame.font.init() 应该只初始化pygame.font?
有人知道为什么会这样和/或有更好的解决方案吗?
Python 版本是 3.6,pygame 版本是 1.9.4。
【问题讨论】:
标签: python-3.x macos pygame