python - 如何打开无法启动的pygame窗口?
问题描述
我正在从“Python Crash Course”制作游戏,但在显示 pygame 窗口时遇到问题。看起来 Python Launcher 应用程序试图启动但没有任何反应,Python Launcher 的图标在 Dock 中弹跳,仅此而已。
import sys
import pygame
def run_game():
#Initilize game and create a screen object.
pygame.init()
pygame.display.init()
screen = pygame.display.set_mode((1200, 800))
pygame.display.set_caption("Alien Invasion")
#Start the main loop for the game.
while True:
# Watch for keyboard and mouse events.
for event in pygame.event.get():
if event.type == pygame.QUIT:
sys.exit()
# Make the most recently drawn screen visible.
pygame.display.flip()
run_game()
知道如何解决吗?非常感谢您的帮助!
更新。我正在使用 MacOS Catalina。
解决方案
推荐阅读
- javascript - 单引号 (') 后的原子红色突出显示
- angular - 无法在应用模块中创建的子模块中实现路由
- spring-boot - Spring Boot 2.0.3 执行器与 Spring Boot 安全 CSRF 无效
- r - 正确评估列表列中的“rlang”表达式
- angular - Angular Universal - 排除路线
- r - Find the complement with the `subset` function in R
- javascript - 将数据格式化为文本,同时在数据表中向 excel 报告,但不工作
- java - 具有依赖注入错误的生产者/消费者模式
- sql - 有多少种方法可以生成将 varchar 转换为不会被 ISNUMERIC() 捕获的数字的错误?
- ssrs-2008 - 如何在 ssrs 单参数中创建父子层次结构