已有183人关注
pygame init 报错
发表在Python图书答疑 2021-01-11 《Python项目开发案例集锦》第4章 玛丽冒险
是否精华
版块置顶:

我在参照书中案例学习时,发现在执行pygame.init() 报错如下:


pygame 2.0.1 (SDL 2.0.14, Python 3.7.2)

Hello from the pygame community. https://www.pygame.org/contribute.html

Fatal Python error: (pygame parachute) Segmentation Fault


Current thread 0x00007f711a78b700 (most recent call first):

  File "/home/zhouyou/projects/FreeTime/marie_adventure/marie.py", line 20 in mainGame

  File "/home/zhouyou/projects/FreeTime/marie_adventure/marie.py", line 37 in <module>

[1]    15227 abort (core dumped)  /home/zhouyou/anaconda3/bin/python3.7 

(base) ➜  FreeTime /home/zhouyou/anaconda3/bin/python3.7 /home/zhouyou/projects/FreeTime/marie_adventure/marie-old.py

pygame 2.0.1 (SDL 2.0.14, Python 3.7.2)

Hello from the pygame community. https://www.pygame.org/contribute.html

Fatal Python error: (pygame parachute) Segmentation Fault


Current thread 0x00007f57bc022700 (most recent call first):

  File "/home/zhouyou/projects/FreeTime/marie_adventure/marie-old.py", line 193 in mainGame

  File "/home/zhouyou/projects/FreeTime/marie_adventure/marie-old.py", line 297 in <module>

[1]    15695 abort (core dumped)  /home/zhouyou/anaconda3/bin/python3.7 


代码片段如下:

import pygame
from pygame.locals import *
import sys

SCREENWIDTH = 822  # Game screen width
SCREENHEIGHT = 199  # Game screen height
FPS = 30  # The time to update the screen


def mainGame():
    global SCREEN, FPSCLOCK
    score = 0
    over = False  # define the game go on or not
    pygame.init()
    FPSCLOCK = pygame.time.Clock()  # control how long for each loops
    SCREEN = pygame.dispaly.set_mode((SCREENWIDTH, SCREENHEIGHT))
    pygame.display.set_caption("玛丽冒险")  # title
    
    while True:
        for event in pygame.event.get():
        if event.type == QUIT:
            pygame.quit()
            sys.exit()
        pygame.display.update()
        FPSCLOCK.tick(FPS)


if __name__ == "__main__":
    mainGame()


分享到:
精彩评论 1
cestlive86
学分:25 LV2
2021-01-11
沙发

使用的是Python 3.7.2 pygame 2.0.1  在Linux 系统下开发

首页上一页 1 下一页尾页 1 条记录 1/1页
手机同步功能介绍
友情提示:以下图书配套资源能够实现手机同步功能
明日微信公众号
明日之星 明日之星编程特训营
客服热线(每日9:00-17:00)
400 675 1066
mingrisoft@mingrisoft.com
吉林省明日科技有限公司Copyright ©2007-2022,mingrisoft.com, All Rights Reserved长春市北湖科技开发区盛北大街3333号长春北湖科技园项目一期A10号楼四、五层
吉ICP备10002740号-2吉公网安备22010202000132经营性网站备案信息 营业执照