Commit 3d4a1082 by BellCodeEditor

auto save

parent f5b47554
Showing with 17 additions and 4 deletions
......@@ -60,8 +60,8 @@ old_sn = 0
block_list =pygame.sprite.Group() # 创建精灵组
with open("record.txt","r",encoding='utf-8')as f:
f1 = f.read()
re = json.loads(f1)
f1 = f.read() #文件读取
re = json.loads(f1) #转化
one = re["第1名"]
two = re["第2名"]
three = re["第3名"]
......@@ -141,6 +141,19 @@ while True:
gameover = pygame.image.load('gameover.png') # 游戏结束
screen.blit(gameover, (400, 200))
gamestate = False
if sn > three:
if sn > one:
re["第1名"]= sn
re["第2名"] = one
re["第3名"] = two
elif sn > two:
re["第2名"] = sn
re["第3名"] = two
else:
re["第3名"] = sn
kp = json.dumps(re,ensure_ascii = False)
with open("record.txt","w",encoding="utf-8")as s:
s.write(kp)
else: #在循环判断精灵碰撞的else里面进行增加分数效果
if sprite.rect.x + sprite.rect.width < wukong.rect.x:
sn += sprite.sn
......
{"第1名": 0, "第2名": 0, "第3名": 0}
\ No newline at end of file
{"第1名": 52, "第2名": 5, "第3名": 5}
\ 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