Commit 482b1407 by BellCodeEditor

save project

parent da1f0bb9
Showing with 16 additions and 15 deletions
...@@ -42,7 +42,7 @@ jumpState = "runing" ...@@ -42,7 +42,7 @@ jumpState = "runing"
t = 30 t = 30
time = 0 time = 0
changex = 0 changex = 0
gamestate = False 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:
...@@ -52,11 +52,12 @@ while True: ...@@ -52,11 +52,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 changex<=-1000:# 路的移动 wukong = Player(hero[index])
changex = 0 if jumpState == "runing": # 跑步状态下
else: index += 1
changex-=8 if index >= 5:
if gamestate==False: index = 0
if gamestate==True:
if jumpState == "up": # 起跳状态 if jumpState == "up": # 起跳状态
if t > 0: if t > 0:
y -= t y -= t
...@@ -72,14 +73,12 @@ while True: ...@@ -72,14 +73,12 @@ while True:
else: else:
jumpState = "runing" jumpState = "runing"
t =30 t =30
if changex<=-1000:# 路的移动
changex = 0
else:
changex-=8
# 悟空造型 # 悟空造型
wukong = Player(hero[index]) # 将背图画上去
if jumpState == "runing": # 跑步状态下
index += 1
if index >= 5:
index = 0
# 将背景图画上去
time+=1 time+=1
if time>=60: if time>=60:
time=0 time=0
...@@ -96,7 +95,10 @@ while True: ...@@ -96,7 +95,10 @@ while True:
sprite.rect.x-=8 sprite.rect.x-=8
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))
gamestate = False
# 刷新画面 # 刷新画面
pygame.display.update() pygame.display.update()
FPS.tick(30) FPS.tick(30)
pygame.sprite.collide_rect()
\ 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