Commit 5dc03fae by BellCodeEditor

save project

parent e8d218f5
Showing with 25 additions and 6 deletions
......@@ -46,9 +46,12 @@ music = pygame.mixer.Sound("score.wav")
with open("record.txt",'r',encoding = "utf-8") as f :
json_txt = f.read()
python_txt = json.loads(json_txt)
first = "第一名:" + str(python_txt["第1名"])
scond = "第二名:" + str(python_txt["第2名"])
third = "第三名:" + str(python_txt["第3名"])
one = python_txt["第1名"]
two = python_txt["第2名"]
three = python_txt["第3名"]
first = "第一名:" + str(one)
scond = "第二名:" + str(two)
third = "第三名:" + str(three)
print(first)
print(scond)
print(third)
......@@ -129,7 +132,23 @@ while True:
if pygame.sprite.collide_rect(wukong, sprite): # 精灵碰撞检测
gameover = pygame.image.load('gameover.png') # 游戏结束
screen.blit(gameover, (400, 200))
# gamestate = False
gamestate = False
if score > three:
if score > one :
python_txt["第1名"] = score
python_txt["第2名"] = one
python_txt["第3名"] = two
elif score > two :
python_txt["第2名"] = score
python_txt["第3名"] = two
else :
python_txt["第3名"] = score
#python_txt = {"第1名": one, "第2名": two, "第3名": three}
new_json = json.dumps(python_txt,ensure_ascii=False)
with open("record.txt","w",encoding = "utf-8") as f :
f.write(new_json)
info = "Score:" + str(score)
my_font = font.render(info,True,(0,0,0))
f_txt = font.render(first,True,(0,0,0))
......
{"第1名": 11, "第2名": 22, "第3名": 33}
\ No newline at end of file
{"第1名": 4, "第2名": 2, "第3名": 0}
\ 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