运行时控制台中出现错误:
--> python3 -m poetry init --no-interaction --name repl_python3_SycoBaksGame
This command will guide you through creating your pyproject.toml config.
You can specify a package in the following forms:
- A single name (requests)
- A name and a constraint (requests ^2.23.0)
- A git url (git+https://github.com/python-poetry/poetry.git)
- A git url with a revision (git+https://github.com/python-poetry/poetry.git#develop)
- A file path (../my-package/my-package.whl)
- A directory (../my-package/)
- An url (https://example.com/packages/my-package-0.1.0.tar.gz)
pygame 1.9.6
Hello from the pygame community. https://www.pygame.org/contribute.html
xcb_connection_has_error() returned true
ALSA lib confmisc.c:767:(parse_card) cannot find card '0'
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
pygame 1.9.6
Hello from the pygame community. https://www.pygame.org/contribute.html
xcb_connection_has_error() returned true
ALSA lib confmisc.c:767:(parse_card) cannot find card '0'
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM default
我的代码:
import pygame
#Canvas Creation
pygame.init()
win = pygame.display.set_mode((500, 500))
pygame.display.set_caption("SycoBaks Game")
#Position
x = 250
y = 250
#Size
width = 20
height = 20
#Velocity/Time
speed = 5
#SycoBak Main GameFrame
run = True
while not run:
pygame.time.delay(100)
for event in pygame.event.get():
if event.type == pygame.QUIT:
run = False
keys = pygame.key.get_pressed()
if keys[pygame.K_LEFT]:
x=x-1
if keys[pygame.K_RIGHT]:
x=x+1
if keys[pygame.K_UP]:
y=y-1
if keys[pygame.K_DOWN]:
y=y+1
pygame.draw.rect(win, (255, 0, 0), (x, y, width, height))
pygame.display.update()
pygame.quit()如果有什么东西帮助我解决了这个错误,我会喜欢的,因为我看到我的代码没有什么问题,这可能是一个游戏依赖问题,但我不知道*
发布于 2020-10-21 06:30:34
pygame.init()所做的是为您初始化在这里显示的所有游戏模块。
我认为这是导入一个需要一些工作(您不需要的)的模块,并强制您执行一些不需要的代码。尝试导入模块,您需要一个接一个。您可以init()您需要的每个模块。
https://stackoverflow.com/questions/64432939
复制相似问题