Commit 4aeacfdf by BellCodeEditor

save project

parent 07cd3ef9
Showing with 4 additions and 3 deletions
...@@ -118,7 +118,7 @@ while True: ...@@ -118,7 +118,7 @@ while True:
gameover=pygame.image.load('gameover.png') gameover=pygame.image.load('gameover.png')
screen.blit(gameover,(400,200))#渲染失败画面 screen.blit(gameover,(400,200))#渲染失败画面
gamestate=False#游戏停止 gamestate=False#游戏停止
if score > three: if score > three: #更新分数
if score > one: if score > one:
record['第1名']=score record['第1名']=score
record['第2名']=one record['第2名']=one
...@@ -128,6 +128,7 @@ while True: ...@@ -128,6 +128,7 @@ while True:
record['第3名']=two record['第3名']=two
else: else:
record['第3名']=score record['第3名']=score
#将字典record转化成json字符串
record=json.dumps(record,ensure_ascii=False) record=json.dumps(record,ensure_ascii=False)
with open('record.txt','w',encoding='utf-8')as f: with open('record.txt','w',encoding='utf-8')as f:
f.write(record) f.write(record)
......
{"第1名": 91, "第2名": 13, "第3名": 8} {"第1名": 91, "第2名": 86, "第3名": 13}
\ No newline at end of file \ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment