Commit c996bf3e by BellCodeEditor

save project

parent 58b3c267
Showing with 9 additions and 5 deletions
...@@ -42,6 +42,7 @@ time = 0 ...@@ -42,6 +42,7 @@ time = 0
road_x = 0 road_x = 0
bg_x = 0 bg_x = 0
wukong = Wukong(hero[0]) wukong = Wukong(hero[0])
gameState = True
while True: while True:
for event in pygame.event.get(): for event in pygame.event.get():
if event.type == locals.QUIT: if event.type == locals.QUIT:
...@@ -65,9 +66,9 @@ while True: ...@@ -65,9 +66,9 @@ while True:
else: else:
jumpState = "runing" jumpState = "runing"
t =30 t =30
if gameState == True:
# 悟空造型 # 悟空造型
wukong.image = hero[index] ` wukong.image = hero[index]
if jumpState == "runing": # 跑步状态下 if jumpState == "runing": # 跑步状态下
index += 1 index += 1
if index >= 5: if index >= 5:
...@@ -95,6 +96,9 @@ while True: ...@@ -95,6 +96,9 @@ while True:
screen.blit(obstacle.image, (obstacle.rect.x, obstacle.rect.y)) screen.blit(obstacle.image, (obstacle.rect.x, obstacle.rect.y))
if obstacle.rect.x <= 0-obstacle.rect.width: if obstacle.rect.x <= 0-obstacle.rect.width:
obstacle.kill() obstacle.kill()
if pygame.sprite.collide_rect(wukong,obstacle):
gameOver = pygame.image.load('gameover.png')
screen.blit(gameOver,(400,200))
gameState = False
pygame.display.update() pygame.display.update()
FPS.tick(60) FPS.tick(60)`
\ 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