Commit 7052df08 by BellCodeEditor

save project

parent 706ff550
Showing with 9 additions and 4 deletions
...@@ -42,7 +42,7 @@ hero = [pygame.image.load('hero1.png'), ...@@ -42,7 +42,7 @@ hero = [pygame.image.load('hero1.png'),
pygame.image.load('hero3.png'), pygame.image.load('hero3.png'),
pygame.image.load('hero4.png'), pygame.image.load('hero4.png'),
pygame.image.load('hero5.png')] pygame.image.load('hero5.png')]
basic_font=pygame.font.Font('STKAITI.TTF',18) basic_font=pygame.font.Font('STKAITI.TTF',30)
score_audio=pygame.mixer.Sound('score.wav') score_audio=pygame.mixer.Sound('score.wav')
index = 0 index = 0
...@@ -56,6 +56,7 @@ gamestate = True ...@@ -56,6 +56,7 @@ gamestate = True
score=0 score=0
speed=8 speed=8
old_score=0 old_score=0
again=0
block_list =pygame.sprite.Group() # 创建精灵组 block_list =pygame.sprite.Group() # 创建精灵组
...@@ -133,8 +134,11 @@ while True: ...@@ -133,8 +134,11 @@ while True:
gameover = pygame.image.load('gameover.png') # 游戏结束 gameover = pygame.image.load('gameover.png') # 游戏结束
screen.blit(gameover,(400, 200)) screen.blit(gameover,(400, 200))
gamestate = False gamestate = False
if gamestate==False:
m=basic_font.render("游戏结束,按任意键重新开始",True,(60,90,60))
screen.blit(m,(350,300))
if score>one: if score>one:
record["第1名"]=score record["第1名"]=score
record["第2名"]=one record["第2名"]=one
record["第3名"]=two record["第3名"]=two
elif score>two: elif score>two:
...@@ -145,6 +149,7 @@ while True: ...@@ -145,6 +149,7 @@ while True:
record=json.dumps(record,ensure_ascii=False) record=json.dumps(record,ensure_ascii=False)
with open('record.txt','w',encoding='utf-8') as f: with open('record.txt','w',encoding='utf-8') as f:
f.write(record) f.write(record)
else: else:
if sprite.rect.x+sprite.rect.width<wukong.rect.x: if sprite.rect.x+sprite.rect.width<wukong.rect.x:
......
{"第1名": 8, "第2名": 4, "第3名": 1} {"第1名": 13, "第2名": 12, "第3名": 8}
\ 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