Commit 8337023a by BellCodeEditor

auto save

parent 5127e967
Showing with 5 additions and 0 deletions
...@@ -54,6 +54,7 @@ gamestate = True ...@@ -54,6 +54,7 @@ gamestate = True
score = 0 score = 0
speed = 8 speed = 8
old_score = 0 old_score = 0
die = False
block_list =pygame.sprite.Group() # 创建精灵组 block_list =pygame.sprite.Group() # 创建精灵组
...@@ -66,6 +67,8 @@ while True: ...@@ -66,6 +67,8 @@ while True:
if jumpState == "runing": if jumpState == "runing":
if event.key == locals.K_SPACE: if event.key == locals.K_SPACE:
jumpState = "up" jumpState = "up"
if event.key == locals.K_D:
die = not die
# 悟空造型 # 悟空造型
wukong = Player(hero[index]) wukong = Player(hero[index])
...@@ -120,6 +123,7 @@ while True: ...@@ -120,6 +123,7 @@ while True:
if pygame.sprite.collide_rect(wukong, sprite): # 精灵碰撞检测 if pygame.sprite.collide_rect(wukong, sprite): # 精灵碰撞检测
gameover = pygame.image.load('gameover.png') # 游戏结束 gameover = pygame.image.load('gameover.png') # 游戏结束
screen.blit(gameover, (400, 200)) screen.blit(gameover, (400, 200))
if die :
gamestate = False gamestate = False
else: else:
if sprite.rect.x+sprite.rect.width<wukong.rect.x: if sprite.rect.x+sprite.rect.width<wukong.rect.x:
...@@ -130,6 +134,7 @@ while True: ...@@ -130,6 +134,7 @@ while True:
scoresy.play() scoresy.play()
old_score = score old_score = score
scoreSurf = basic_font.render("分数:"+str(score),True,(255,0,0)) scoreSurf = basic_font.render("分数:"+str(score),True,(255,0,0))
dieXX = basic_font.render("是否死亡"+str(die),True,(255,0,0))
screen.blit(scoreSurf,(850,20)) screen.blit(scoreSurf,(850,20))
# 刷新画面 # 刷新画面
......
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