Commit 7a6f1ad2 by BellCodeEditor

save project

parent 300e3304
Showing with 16 additions and 14 deletions
...@@ -38,6 +38,7 @@ shan_x=0 ...@@ -38,6 +38,7 @@ shan_x=0
index = 0 index = 0
road_x=0 road_x=0
time=0 time=0
gamestate=True
y = 400 y = 400
jumpState = "runing" jumpState = "runing"
t = 30 t = 30
...@@ -52,20 +53,20 @@ while True: ...@@ -52,20 +53,20 @@ 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 gamestate == True:
if jumpState == "up": # 起跳状态 if jumpState == "up": # 起跳状态
if t > 0: if t > 0:
y -= t y -= t
t -= 2 t -= 2
else: else:
jumpState = "down" jumpState = "down"
if jumpState == "down": # 降落状态 if jumpState == "down": # 降落状态
if t <= 30: if t <= 30:
y += t y += t
t += 2 t += 2
else: else:
jumpState = "runing" jumpState = "runing"
t =30 t =30
# 悟空造型 # 悟空造型
wukong = Player(hero[index] wukong = Player(hero[index]
...@@ -103,6 +104,7 @@ while True: ...@@ -103,6 +104,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))
gamestate=False
# 刷新画面 # 刷新画面
pygame.display.update() pygame.display.update()
......
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