Commit e1a5e96f by BellCodeEditor

save project

parent d09c8cc8
Showing with 18 additions and 5 deletions
...@@ -57,7 +57,7 @@ with open("score.txt","r",encoding="utf-8") as f: ...@@ -57,7 +57,7 @@ with open("score.txt","r",encoding="utf-8") as f:
three=record["第3名"] three=record["第3名"]
while True: while True:
speed=8+score//3 speed=8+score//1
if score>old_score: if score>old_score:
music_1.play() music_1.play()
old_score=score old_score=score
...@@ -117,6 +117,19 @@ while True: ...@@ -117,6 +117,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))
gameover1=False gameover1=False
if score > three:
if score > one:
record["第1名"] = score
record["第2名"] = one
record["第3名"] = two
elif score > two:
record["第2名"] = score
record["第3名"] = two
else:
record["第3名"] = score
record = json.dumps(record,ensure_ascii = False)
with open("score.txt","w",encoding = "utf-8") as file1:
file1.write(record)
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
...@@ -133,4 +146,4 @@ while True: ...@@ -133,4 +146,4 @@ while True:
three_1=font.render("第三名:"+str(three),True,(255,255,255)) three_1=font.render("第三名:"+str(three),True,(255,255,255))
screen.blit(three_1,(880,80)) screen.blit(three_1,(880,80))
pygame.display.update() pygame.display.update()
FPS.tick(60) FPS.tick(60)
\ No newline at end of file \ No newline at end of file
{"第1名": 0, "第2名": 0, "第3名": 0} {"第1名": 33, "第2名": 5, "第3名": 1}
\ 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