Commit 18100dda by BellCodeEditor

save project

parent d9b6796c
Showing with 16 additions and 10 deletions
......@@ -46,7 +46,7 @@ bg_x = 0
road_x = 0
block_list=pygame.sprite.Group()
# 创建障碍物
gamestatu=True
while True:
for event in pygame.event.get():
......@@ -57,27 +57,30 @@ while True:
if jumpState == "runing":
if event.key == locals.K_SPACE:
jumpState = "up"
wukong = Player(hero[index])
if jumpState == "runing": # 跑步状态下
index += 1
if index >= 5:
index = 0
if gamestatu==True:
if jumpState == "up": # 起跳状态
if t > 0:
y -= t
wukong.rect.y=y
t -= 2
else:
jumpState = "down"
if jumpState == "down": # 降落状态
if t <= 30:
y += t
wukong.rect.y=y
t += 2
else:
jumpState = "runing"
t =30
# 悟空造型
wukong = Player(hero[index])
if jumpState == "runing": # 跑步状态下
index += 1
if index >= 5:
index = 0
# 将背景图画上去
bg_x -= 1
if bg_x<=-1000:
......@@ -100,10 +103,13 @@ while True:
screen.blit(sprite.image,(sprite.rect.x,sprite.rect.y))
if sprite.rect.x<0-sprite.rect.width:
sprite.kill()
print(len(block_list))
# ++++++++++++++++++++++
if pygame.sprite.collide_rect(wukong,sprite):
gameover=pygame.image.load("gameover.png")
screen.blit(gameover,(400,200))
gamestatu=False
# ++++++++++++++++++++++
# ++++++++++++++++++++++
# ++++++++++++++++++++++
# 刷新画面
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