Commit 068c9cdf by BellCodeEditor

save project

parent 4b35b32a
Showing with 21 additions and 6 deletions
......@@ -112,7 +112,7 @@ while True:
screen.blit(road, (road_x, 500)) # 道路
screen.blit(wukong.image, (150, y)) # 悟空
time += 1
if time >= 60: # 创建障碍物精灵
time = 0
......@@ -129,17 +129,30 @@ while True:
gameover = pygame.image.load('gameover.png') # 游戏结束
screen.blit(gameover, (400, 200))
gamestate = 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 s:
s.write(record)
else:
if sprite.rect.x+sprite.rect.width<wukong.rect.x:
score+=sprite.score
sprite.score=0
scoreSurf=basic_font.render("分数:"+str(score),True,(255,255,255))
screen.blit(scoreSurf,(880,20))
scoreSurf=basic_font.render("第1名:"+str(score),True,(255,255,255))
scoreSurf=basic_font.render("第1名:"+str(one),True,(255,255,255))
screen.blit(scoreSurf,(880,50))
scoreSurf=basic_font.render("第2名:"+str(score),True,(255,255,255))
scoreSurf=basic_font.render("第2名:"+str(two),True,(255,255,255))
screen.blit(scoreSurf,(880,80))
scoreSurf=basic_font.render("第2名:"+str(score),True,(255,255,255))
scoreSurf=basic_font.render("第2名:"+str(three),True,(255,255,255))
screen.blit(scoreSurf,(880,110))
# 刷新画面
if old_score<score:
......
{"第1名": 4, "第2名": 0, "第3名": 0}
\ No newline at end of file
{"第1名": 0, "第2名": 0, "第3名": 0}
\ No newline at end of file
{"第1名": 2, "第2名": 1, "第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