Pygame 正在打开无响应 window
Pygame is opening a not responding window
我正在创建我的第一个 PyGame program.When 我 运行 我的程序 window 应该 PyGame window 应该打开但是每当我运行 程序无响应window 已打开。
这是我的代码:
import pygame
pygame.init()
screen = pygame.display.set_mode((500,500))
每当我 运行 它打开一个没有响应的 PyGame window。我该如何解决?
我在网上搜索了解决方案,但 none 有效。
还有:
当我添加 pygame.event.get()
时,它会打开 window 并立即关闭它。
我在 MacOS Visual Studio 代码上使用 Python 3.9.9
试试这个
import pygame
pygame.init()
screen = pygame.display.set_mode((500,500))
black = (0, 0, 0)
running = True
while running:
print(screen)
screen.fill(black)
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
pygame.display.flip()
pygame.display.update()
pygame.quit()
在 'black' 变量中,您可以通过转到 google 并搜索 'rgb color selector' select 颜色并复制 rgb 部分来选择另一种颜色
我正在创建我的第一个 PyGame program.When 我 运行 我的程序 window 应该 PyGame window 应该打开但是每当我运行 程序无响应window 已打开。
这是我的代码:
import pygame
pygame.init()
screen = pygame.display.set_mode((500,500))
每当我 运行 它打开一个没有响应的 PyGame window。我该如何解决?
我在网上搜索了解决方案,但 none 有效。
还有:
当我添加 pygame.event.get()
时,它会打开 window 并立即关闭它。
我在 MacOS Visual Studio 代码上使用 Python 3.9.9
试试这个
import pygame
pygame.init()
screen = pygame.display.set_mode((500,500))
black = (0, 0, 0)
running = True
while running:
print(screen)
screen.fill(black)
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
pygame.display.flip()
pygame.display.update()
pygame.quit()
在 'black' 变量中,您可以通过转到 google 并搜索 'rgb color selector' select 颜色并复制 rgb 部分来选择另一种颜色