Commit d57ad405 by BellCodeEditor

save project

parent 5d496c2d
Showing with 37 additions and 32 deletions
......@@ -42,6 +42,7 @@ time=0
road_x=0
bg_x=0
wukong=wukong(hero[0])
gameState=True
while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
......@@ -66,36 +67,40 @@ while True:
jumpState = "runing"
t =30
# 悟空造型
wukong.image = hero[index]
if jumpState == "runing": # 跑步状态下
index += 1
if index >= 5:
index = 0
# 将背景图画上去
bg_x-=1
if bg_x<=-1000:
bg_x=0
screen.blit(background, (bg_x, 0))
road_x-=8
if road_x<=-1000:
road_x=0 # 远处背景
screen.blit(road, (road_x, 500)) # 路
screen.blit(wukong.image, (wukong.rect.x, wukong.rect.y)) # 悟空
if gameState==True:
# 悟空造型
wukong.image = hero[index]
if jumpState == "runing": # 跑步状态下
index += 1
if index >= 5:
index = 0
# 将背景图画上去
bg_x-=1
if bg_x<=-1000:
bg_x=0
screen.blit(background, (bg_x, 0))
road_x-=8
if road_x<=-1000:
road_x=0 # 远处背景
screen.blit(road, (road_x, 500)) # 路
screen.blit(wukong.image, (wukong.rect.x, wukong.rect.y)) # 悟空
time+=1
if time>=60:
time=0
jian=random.randint(0,5)
if jian>=2:
obstacle =Block(bush, stone, cacti)
block_list.add(obstacle)
for obstacle in block_list:
obstacle.rect.x -= 8
screen.blit(obstacle.image, (obstacle.rect.x,obstacle.rect.y))
if obstacle.rect.x <= 0- obstacle.rect.width:
obstacle.kill()
# 刷新画面
pygame.display.update()
FPS.tick(60)
\ No newline at end of file
time+=1
if time>=60:
time=0
jian=random.randint(0,5)
if jian>=2:
obstacle =Block(bush, stone, cacti)
block_list.add(obstacle)
for obstacle in block_list:
obstacle.rect.x -= 8
screen.blit(obstacle.image, (obstacle.rect.x,obstacle.rect.y))
if obstacle.rect.x <= 0- obstacle.rect.width:
obstacle.kill()
if pygame.sprite.collide_rect(wukong,obstacle):
gameOver=pygame.image.load('gameover.png'
gameState=False
# 刷新画面
pygame.display.update()
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