微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Pygame.init() 错误:致命的 Python 错误:pygame 降落伞分段错误

如何解决Pygame.init() 错误:致命的 Python 错误:pygame 降落伞分段错误

我用python开发了一个小游戏,比如超级玛丽,在执行pygame.init()时遇到问题,下面是完整代码

使用 Python 3.7.2 pygame 2.0.1 Ubuntu 16.04

在 vscode 中运行时,遇到以下错误

pygame 2.0.1 (SDL 2.0.14,Python 3.7.2) Hello from the pygame community. 
pygame.org/contribute.html Fatal Python error: (pygame parachute) Segmentation Fault 

Current thread 0x00007f21f417d700 (most recent call first): 
File "/home/zhouyou/projects/FreeTime/marie_adventure/marie.py",line 41 in mainGame 
File "/home/zhouyou/projects/FreeTime/marie_adventure/marie.py",line 56 in <module> [1] 26264 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

class Map():
    def __init__(self,x,y):
        # load background image
        self.backgroud = pygame.image.load("images/bg.png").convert_alpha()
        self.x = x
        self.y = y

    def map_rolling(self):
        if self.x < -790: # if the map x-axis in (-795-800),means it is still moving in the expeted range
            self.x = 800
        else:
            self.x -= 5

    def map_update(self):
        SCREEN.bilt(self.backgroud,(self.x,self.y))


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()

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。