Commit e6933f01 by BellCodeEditor

save project

parent a64994bf
Showing with 6 additions and 3 deletions
...@@ -47,6 +47,7 @@ while True: ...@@ -47,6 +47,7 @@ while True:
if event.key == locals.K_SPACE: if event.key == locals.K_SPACE:
jumpState = "up" jumpState = "up"
if gamestate==True:
if jumpState == "up": # 起跳状态 if jumpState == "up": # 起跳状态
if t > 0: if t > 0:
y -= t y -= t
...@@ -62,7 +63,7 @@ while True: ...@@ -62,7 +63,7 @@ while True:
t =30 t =30
# 悟空造型 # 悟空造型
wukong = hero[index] wukong = Player(hero[index])
if jumpState == "runing": # 跑步状态下 if jumpState == "runing": # 跑步状态下
index += 1 index += 1
if index >= 5: if index >= 5:
...@@ -91,10 +92,13 @@ while True: ...@@ -91,10 +92,13 @@ while True:
if sprite.rect_x<=0-sprite.rect.width: if sprite.rect_x<=0-sprite.rect.width:
sprite.kill() # 障碍物消失 sprite.kill() # 障碍物消失
# 创建障碍物对象 # 创建障碍物对象
if pygame.sprite.collide_rect(wukong,sprite):
gameover=pygame.image.load('gameover.png')
screen.blit(gameover,(400,200))
screen.blit(obstacle.image, (obstacle.rect.x, obstacle.rect.y))
# 刷新画面 # 刷新画面
pygame.display.update() pygame.display.update()
FPS.tick(60) FPS.tick(60)
\ 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