Commit 68502571 by BellCodeEditor

save project

parent 4090af3f
Showing with 11 additions and 26 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:
...@@ -69,32 +67,20 @@ while True: ...@@ -69,32 +67,20 @@ while True:
index = 0 index = 0
# 将背景图画上去 # 将背景图画上去
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: screen.blit(wukong, (150, y))
road_x = 0 # 悟空 if background_x < -1000:
screen.blit(wukong, (150, y)) background_x = 0 # 悟空
time += 1
if time >= 60:
r = random.randint(0,100)
if r > 40:
obstacle = Abc(stone,cacti,bush)
Abc_list.add(obstacle)
time = 0
for prop in Abc_list: if road_x <-1000:
prop.rect.x -= 8 road_x = 0
screen.blit(prop.image, (prop.rect.x, prop.rect.y)) if obstacle.rect.x <= 0-obstacle.rect.width: # 障碍物消失
if prop.rect.x <= 0 - prop.rect.width: obstacle = Abc(stone,cacti,bush)
prop.kill() obstacle.rect.x -= 8
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