Commit 68502571 by BellCodeEditor

save project

parent 4090af3f
Showing with 8 additions and 23 deletions
...@@ -34,9 +34,7 @@ jumpState = "runing" ...@@ -34,9 +34,7 @@ jumpState = "runing"
t = 30 t = 30
road_x = 0 road_x = 0
background_x = 0 background_x = 0
time = 0 obstacle = Abc(stone,cacti,bush)
#obstacle = Abc(stone,cacti,bush)
Abc_list = pygame.sprite.Group()
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:
...@@ -70,31 +68,19 @@ while True: ...@@ -70,31 +68,19 @@ while True:
# 将背景图画上去 # 将背景图画上去
background_x -= 2 background_x -= 2
screen.blit(background, (background_x, 0)) screen.blit(background, (background_x, 0))
if background_x < -1000:
background_x = 0
road_x -= 8 # 远处背景 road_x -= 8 # 远处背景
screen.blit(road, (road_x, 500)) # 路 screen.blit(road, (road_x, 500)) # 路
if road_x < -1000:
road_x = 0 # 悟空
screen.blit(wukong, (150, y)) screen.blit(wukong, (150, y))
if background_x < -1000:
background_x = 0 # 悟空
if road_x <-1000:
time += 1 road_x = 0
if time >= 60: if obstacle.rect.x <= 0-obstacle.rect.width: # 障碍物消失
r = random.randint(0,100)
if r > 40:
obstacle = Abc(stone,cacti,bush) obstacle = Abc(stone,cacti,bush)
Abc_list.add(obstacle) obstacle.rect.x -= 8
time = 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()
screen.blit(obstacle.image, (obstacle.rect.x, obstacle.rect.y))
# 刷新画面 # 刷新画面
print(len(Abc_list))
pygame.display.update() pygame.display.update()
FPS.tick(60) 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