Commit 24999950 by BellCodeEditor

save project

parent fc354d65
Showing with 27 additions and 11 deletions
......@@ -47,7 +47,7 @@ basic_font=pygame.font.Font("STKAITI.TTF",18)
index = 0
y = 400
jumpState = "runing"
t = 30
t = 30
road_x = 0
bg_x = 0
......@@ -116,7 +116,7 @@ while True:
time = 0
num = random.randint(0,50)
if num > 20:
obstacle = Block(bush,cacti,stone)
obstacle = Block(bush,cacti,stone )
block_list.add(obstacle)
for sprite in block_list: # 遍历、展示障碍物精灵
sprite.rect.x -= speed
......@@ -127,22 +127,38 @@ while True:
gameover = pygame.image.load('gameover.png') # 游戏结束
screen.blit(gameover, (400, 200))
gamestate = False
if score>one:
record["第1名"] =score
record["第2名"] =one
record["第3名"] =two
elif score>two:
record["第2名"] =score
record["第3名"] =two
elif score>three:
record["第3名"] =score
record= json.dumps(record,ensure_ascii=False)
with open ("record.txt","w",encoding="utf-8") as s:
s.write(record)
else:
if (sprite.rect.x+sprite.rect.width)< wukong.rect.x:
score+=sprite.score
print(score)
sprite.score=0
score+=sprite.score
sprite.score=0
# 刷新画面
if score>old_score:
score_audio.play()
scoresurf= basic_font.render("分数"+str(score),True,(255,255,255))
scoresurf= basic_font.render("分数"+str(score),True,(255,255,255))
screen.blit(scoresurf,(880,20))
scoresurf= basic_font.render("第1名"+str(one),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(two),True,(255,255,255))
scoresurf= basic_font.render("第2名"+str(two),True,(255,255,255))
screen.blit(scoresurf,(880,80))
scoresurf= basic_font.render("第3名"+str(three),True,(255,255,255))
scoresurf= basic_font.render("第3名"+str(three),True,(255,255,255))
screen.blit(scoresurf,(880,110))
......
{"第1名": 0, "第2名": 0, "第3名": 0}
\ No newline at end of file
{"第1名": 4, "第2名": 3, "第3名": 2}
\ 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