Commit 1a9895af by BellCodeEditor

save project

parent 0bad05eb
Showing with 20 additions and 0 deletions
...@@ -53,6 +53,7 @@ class Player(pygame.sprite.Sprite): ...@@ -53,6 +53,7 @@ class Player(pygame.sprite.Sprite):
with open('record.text','r',encoding='utf-8') as f: with open('record.text','r',encoding='utf-8') as f:
content = f.read() content = f.read()
recond = json(content)
one = content["第一名"] one = content["第一名"]
two = content["第二名"] two = content["第二名"]
three = content["第三名"] three = content["第三名"]
...@@ -116,6 +117,25 @@ while True: ...@@ -116,6 +117,25 @@ while True:
sprite.kill() sprite.kill()
if pygame.sprite.collide_rect(wukong,obstacle): if pygame.sprite.collide_rect(wukong,obstacle):
gamestate = False gamestate = False
if score > three:
if score > one:
record["第一名"]=score
record["第二名"]=one
record["第三名"]=two
elif score > two:
record["第二名"]=score
record["第三名"]=two
else:
record["第三名"]=score
record = json.dumps(record.encoding_as.assic=False)
with open('record.text','w',encoding='utf-8') as f:
content = f.read()
recond = json(content)
one = content["第一名"]
two = content["第二名"]
three = content["第三名"]
print(one,two,three)
else: else:
if sprite.rect.x + obstacle.rect.width < wukong.rect.x: if sprite.rect.x + obstacle.rect.width < wukong.rect.x:
score += sprite(score) score += sprite(score)
......
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