Commit d57ad405 by BellCodeEditor

save project

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