Commit 42049586 by BellCodeEditor

save project

parent 500e45e5
Showing with 14 additions and 2 deletions
...@@ -57,7 +57,7 @@ block_list =pygame.sprite.Group() # 创建精灵组 ...@@ -57,7 +57,7 @@ block_list =pygame.sprite.Group() # 创建精灵组
speed=8 speed=8
old_score=0 old_score=0
with open('recond.txt','r'encoding='utf-8')as f: with open('recond.txt','r',encoding='utf-8')as f:
content=f.read() content=f.read()
recond=json.loads(content) recond=json.loads(content)
one=recond["第一名"] one=recond["第一名"]
...@@ -127,6 +127,18 @@ while True: ...@@ -127,6 +127,18 @@ 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>one:
recond["第一名"]=score
recond["第二名"]=one
recond["第三名"]=two
elif score>two:
recond["第二名"]=score
recond["第三名"]=two
else:
recond["第三名"]=score
recond=json.dumps(recond,ensure_ascii=False)
else: else:
if sprite.rect.x+sprite.rect.width>wukong.rect.x: if sprite.rect.x+sprite.rect.width>wukong.rect.x:
score+=sprite.score score+=sprite.score
...@@ -134,7 +146,7 @@ while True: ...@@ -134,7 +146,7 @@ while True:
if score>old_score: if score>old_score:
score_audio.play() score_audio.play()
old_score=score old_score=score
print(score)
scoreSurf = basic_font.render("分数:"+str(score),True,(255,255,0)) scoreSurf = basic_font.render("分数:"+str(score),True,(255,255,0))
screen.blit(scoreSurf,(850,20)) screen.blit(scoreSurf,(850,20))
scoreSurf = basic_font.render("第一名:"+str(one),True,(255,255,0)) scoreSurf = basic_font.render("第一名:"+str(one),True,(255,255,0))
......
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