Commit 68502571 by BellCodeEditor

save project

parent 4090af3f
Showing with 11 additions and 26 deletions
......@@ -34,9 +34,7 @@ jumpState = "runing"
t = 30
road_x = 0
background_x = 0
time = 0
#obstacle = Abc(stone,cacti,bush)
Abc_list = pygame.sprite.Group()
obstacle = Abc(stone,cacti,bush)
while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
......@@ -69,32 +67,20 @@ while True:
index = 0
# 将背景图画上去
background_x -= 2
screen.blit(background, (background_x, 0))
if background_x < -1000:
background_x = 0
screen.blit(background, (background_x, 0))
road_x -= 8 # 远处背景
screen.blit(road, (road_x, 500)) # 路
if road_x < -1000:
road_x = 0 # 悟空
screen.blit(wukong, (150, y))
time += 1
if time >= 60:
r = random.randint(0,100)
if r > 40:
obstacle = Abc(stone,cacti,bush)
Abc_list.add(obstacle)
time = 0
screen.blit(wukong, (150, y))
if background_x < -1000:
background_x = 0 # 悟空
for prop in Abc_list:
prop.rect.x -= 8
screen.blit(prop.image, (prop.rect.x, prop.rect.y))
if prop.rect.x <= 0 - prop.rect.width:
prop.kill()
if road_x <-1000:
road_x = 0
if obstacle.rect.x <= 0-obstacle.rect.width: # 障碍物消失
obstacle = Abc(stone,cacti,bush)
obstacle.rect.x -= 8
screen.blit(obstacle.image, (obstacle.rect.x, obstacle.rect.y))
# 刷新画面
print(len(Abc_list))
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