python - Python + Pygame;screen.fill() 崩溃窗口
问题描述
每当我尝试在我的 pygame 代码中包含“screen.fill(在此处插入值)”时,窗口都会立即崩溃。我可以把它注释掉,我的代码工作得很好。我真的不知道为什么。
我试过移动线路,部分使用其他人的代码 - 没有运气。
import pygame
pygame.init()
win = pygame.display.set_mode((1000, 800))
pygame.display.set_caption("Tetris")
img=pygame.image.load("C:\\Users\\Charlotte\\Desktop\\tetris_grid.png")
win.blit(img,(450, 150))
running = True
while running:
screen.fill(0, 0, 0)
pygame.display.update()
pygame.time.delay(100)
for event in pygame.event.get():
if event.type == pygame.QUIT:
run = False
pygame.quit()
当我运行包含该行的代码时,窗口会打开,然后立即关闭。
解决方案
推荐阅读
- css - 在 Outlook 2010 的电子邮件中选择表的第一个子项
- sql - SQL查找所有注册学生数量超过该课程允许的enroll_limit的课程
- java - 使用 StringBuilder 进行字符串连接
- vba - VBA执行完整循环
- jquery - 使用 bootstrap-float-label css 引导输入密码显示隐藏
- visual-studio-code - 我无法使用新的应用程序链接语法打开 Visual Studio Code 工作区
- python - 使用可变 obj 转换为列表推导
- kotlin-exposed - 当使用 Exposed 的方法“createMissingTablesAndColumns”时,我得到一个 NoSuchElementException
- c# - 如何以编程方式设置按钮样式(第 2 部分)?
- nginx - nginx转发同域请求