首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >游戏开始运行时出错

游戏开始运行时出错
EN

Stack Overflow用户
提问于 2020-10-19 18:07:40
回答 1查看 217关注 0票数 0

运行时控制台中出现错误:

代码语言:javascript
复制
--> 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
 

我的代码:

代码语言:javascript
复制
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()

如果有什么东西帮助我解决了这个错误,我会喜欢的,因为我看到我的代码没有什么问题,这可能是一个游戏依赖问题,但我不知道*

EN

回答 1

Stack Overflow用户

发布于 2020-10-21 06:30:34

pygame.init()所做的是为您初始化在这里显示的所有游戏模块。

我认为这是导入一个需要一些工作(您不需要的)的模块,并强制您执行一些不需要的代码。尝试导入模块,您需要一个接一个。您可以init()您需要的每个模块。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64432939

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档