Commit c996bf3e by BellCodeEditor

save project

parent 58b3c267
Showing with 37 additions and 33 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:
......@@ -65,36 +66,39 @@ while True:
else:
jumpState = "runing"
t =30
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
` 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()
if pygame.sprite.collide_rect(wukong,obstacle):
gameOver = pygame.image.load('gameover.png')
screen.blit(gameOver,(400,200))
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