【发布时间】:2013-05-27 15:29:37
【问题描述】:
我用 python 制作了一个简单的赛车游戏,里面有 pygame、easygui 和 shelve。我完成了游戏,它在空闲和我的 .desktop 文件中都运行良好。之后我决定尝试添加一个高分系统。系统在空闲时工作得很好,但是从 .desktop 文件中我得到一个错误“致命的 python 错误:(pygame parachute)分段错误。”我真的很想将高分系统留在游戏中,因此我们将不胜感激。`
if hero.colliderect(finishline):
starttimer=0
running=0
d=shelve.open('highscores.txt')
highscore=d['highscore']
if time<highscore:
d=shelve.open('highscores.txt')
d['highscore']=time
player=easygui.enterbox(msg=("Congratulations you have set the new highscore of "+str(time)+ " please enter your name"))
d['player']=player
d.close
if time>highscore:
d=shelve.open('highscores.txt')
player=d['player']
highscore=d['highscore']
d.close
easygui.msgbox(msg=("Congratulations you have finished with a time of "+str(time)+" The highscore is "+str(highscore)+ "set by "+player))
`
【问题讨论】:
标签: python pygame shelve easygui