Commit 72e57a37 by BellCodeEditor

save project

parent 26ccace0
Showing with 10 additions and 10 deletions
...@@ -127,19 +127,19 @@ while True: ...@@ -127,19 +127,19 @@ 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#变为False gamestate = False#变为False
if score > thr: if score > thr:#如果分数大于第三名的分数
if score >one: if score >one:#如果比第一名大
record['第1名'] = score record['第1名'] = score#第一名的分数变为现在第一名的分数
record['第2名'] = one record['第2名'] = one#第二名变为之前第一名的分数
record['第3名'] = two record['第3名'] = two#同理
elif score > two: elif score > two:#如果比第一名大
record['第2名'] = score record['第2名'] = score
record['第3名'] = thr record['第3名'] = thr
else: else:
record['第3名'] = score record['第3名'] = score
record = json.dumps(record,ensure_ascii=False) nrecord = json.dumps(record,ensure_ascii=False)#把python字典转换为json字符串
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(nrecord)#输入最新文件(重置排名)
else: else:
if prop.rect.x + prop.rect.width <wukong.rect.x: if prop.rect.x + prop.rect.width <wukong.rect.x:
score += prop.score score += prop.score
......
{"第1名": 1, "第2名": 0, "第3名": 0} {"第1名": 2, "第2名": 1, "第3名": 0}
\ 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