Commit a0ace8db by BellCodeEditor

save project

parent d47f99ca
Showing with 16 additions and 7 deletions
......@@ -42,6 +42,7 @@ block_list=pygame.sprite.Group()
time=0
road_x=0
bg_x=0
gamestatu=True
while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
......@@ -51,16 +52,23 @@ while True:
if jumpState == "runing":
if event.key == locals.K_UP:
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"
......@@ -72,12 +80,8 @@ while True:
bg_x=0
bg_x-=2
# 悟空造型
wukong =Player(hero[index])
if jumpState == "runing": # 跑步状态下
index += 1
if index >= 5:
index = 0
# 将背景图画上去
screen.blit(background, (bg_x, 0)) # 远处背景
screen.blit(road, (road_x, 500)) # 路
......@@ -94,6 +98,11 @@ while True:
screen.blit(sprite.image,(sprite.rect.x,sprite.rect.y))
if sprite.rect.x<0-sprite.rect.width:
sprite.kill()
if pygame.sprite.collide_rect(wukong,sprite):
gameover=pygame.image.load('gameover.png')
screen.blit(gnmeover,(400,200))
gamestatu=False
# 刷新画面
......
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