Commit c7a81cd0 by BellCodeEditor

save project

parent dbfc61f9
Showing with 23 additions and 23 deletions
......@@ -48,7 +48,7 @@ score_audio = pygame.mixer.Sound('score.wav')
index = 0
y = 400
jumpState = "runing"
t = 30
t = 35
score=0
road_x = 0
bg_x = 0
......@@ -91,13 +91,13 @@ while True:
else:
jumpState = "down"
if jumpState == "down": # 降落状态
if t <= 30:
if t <= 35:
y += t
wukong.rect.y = y
t += 2
else:
jumpState = "runing"
t =30
t =35
# 将背景图画上去
......@@ -107,7 +107,7 @@ while True:
screen.blit(background, (bg_x, 0)) # 远景
road_x -= speed
if road_x<=-1000:
if road_x <= -1000:
road_x = 0
screen.blit(road, (road_x, 500)) # 道路
......@@ -129,36 +129,36 @@ 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
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['第3名'] = score
record=json.dumps(record,ensure_ascii=False)
with open('record.txt','w',encoding='utf-8') as f:
f.write(record)
else:
if sprite.rect.x+sprite.rect.width<wukong.rect.x:
score+=sprite.score
sprite.score=0
if sprite.rect.x + sprite.rect.width < wukong.rect.x:
score += sprite.score
sprite.score = 0
if score>old_score:
score_audio.play()
old_score=score
scoreSurf = basic_font.render("分数:"+str(score),True,(0,0,0))
scoreSurf = basic_font.render("分数:" + str(score),True,(0,0,0))
screen.blit(scoreSurf,(850,20))
scoreSurf = basic_font.render("第一名:"+str(one),True,(0,0,0))
screen.blit(scoreSurf,(850,50))
scoreSurf = basic_font.render("第二名:"+str(two),True,(0,0,0))
scoreSurf = basic_font.render("第一名:" + str(one),True,(0,0,0))
screen.blit(scoreSurf,(850,50))
scoreSurf = basic_font.render("第二名:" + str(two),True,(0,0,0))
screen.blit(scoreSurf,(850,80))
scoreSurf = basic_font.render("第三名:"+str(three),True,(0,0,0))
scoreSurf = basic_font.render("第三名:" + str(three),True,(0,0,0))
screen.blit(scoreSurf,(850,110))
# 刷新画面
pygame.display.update()
......
{"第1名": 1, "第2名": 1, "第3名": 0}
\ No newline at end of file
{"第1名": 0, "第2名": 0, "第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