Commit b38035f5 by BellCodeEditor

save project

parent 16663e79
Showing with 8 additions and 2 deletions
...@@ -42,6 +42,7 @@ road_x = 0 ...@@ -42,6 +42,7 @@ road_x = 0
bg_x=0 bg_x=0
obstacle=Black(bush,stone,cacti) obstacle=Black(bush,stone,cacti)
time=0 time=0
gamestate = True
block_list=pygame.sprite.Group() block_list=pygame.sprite.Group()
while True: while True:
for event in pygame.event.get(): for event in pygame.event.get():
...@@ -52,10 +53,12 @@ while True: ...@@ -52,10 +53,12 @@ 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:
wukong = Player(hero[index])
if jumpState == "up": # 起跳状态 if jumpState == "up": # 起跳状态
if t > 0: if t > 0:
y -= t y -= t
wukong.rect.y = y
t -= 2 t -= 2
else: else:
jumpState = "down" jumpState = "down"
...@@ -69,7 +72,7 @@ while True: ...@@ -69,7 +72,7 @@ while True:
t =30 t =30
# 悟空造型 # 悟空造型
wukong = Player(hero[index])
if jumpState == "runing": # 跑步状态下 if jumpState == "runing": # 跑步状态下
index += 1 index += 1
if index >= 5: if index >= 5:
...@@ -86,6 +89,7 @@ while True: ...@@ -86,6 +89,7 @@ while True:
screen.blit(road, (road_x, 500)) # 路 screen.blit(road, (road_x, 500)) # 路
screen.blit(wukong.image, (150, y)) # 悟空 screen.blit(wukong.image, (150, y)) # 悟空
if obstacle.rect.x <= 0-obstacle.rect.width: # 障碍物消失 if obstacle.rect.x <= 0-obstacle.rect.width: # 障碍物消失
# 创建障碍物对象 # 创建障碍物对象
obstacle=Black(bush,stone,cacti) obstacle=Black(bush,stone,cacti)
time += 1 time += 1
...@@ -104,6 +108,7 @@ while True: ...@@ -104,6 +108,7 @@ 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
# 刷新画面 # 刷新画面
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