问题描述
运行时控制台出现错误:
--> 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),(x,y,width,height))
pygame.display.update()
pygame.quit()
如果有什么可以帮助我解决此错误的代码,因为我认为自己的代码没有问题,那将是一个pygame依赖问题,但我不知道 *
解决方法
pygame.init()
做的是尝试为您shown here初始化所有的pygame模块
我认为这是在导入需要一些工作(不需要)的模块,并强迫您执行一些不需要的代码。尝试导入您需要的模块。
您可以init()
所需的每个模块。