Commit ca10315b by BellCodeEditor

save project

parent eba81d69
Showing with 24 additions and 9 deletions
...@@ -32,8 +32,9 @@ nu = 30 ...@@ -32,8 +32,9 @@ nu = 30
#获取障碍x,y #获取障碍x,y
road_x=0 road_x=0
bg_x = 0 bg_x = 0
zhuangzhe = Block(stone,cacti,bush) time = 0
#zhuangzhe = Block(stone,cacti,bush)
block_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:
...@@ -71,20 +72,34 @@ while True: ...@@ -71,20 +72,34 @@ while True:
bg_x -= 1 bg_x -= 1
if bg_x <= -1000: if bg_x <= -1000:
bg_x = 0 bg_x = 0
screen.blit(background, (bg_x, 0)) screen.blit(background, (bg_x, 0))
road_x -= 8 road_x -= 8
if road_x <= -1000: if road_x <= -1000:
road_x = 0 road_x = 0
screen.blit(road, (road_x, 500)) screen.blit(road, (road_x, 500))
# 将背景图画上去 # 将背景图画上去
screen.blit(wukong, (150, y)) screen.blit(wukong, (150, y))
# 刷新画面 # 刷新画面
if zhuangzhe.rect.x <= 0-zhuangzhe.rect.width: #if zhuangzhe.rect.x <= 0-zhuangzhe.rect.width:
zhuangzhe = Block(stone,cacti,bush) #zhuangzhe = Block(stone,cacti,bush)
zhuangzhe.rect.x -= 8 # zhuangzhe.rect.x -= 8
time += 1
if time >= 60:
time = 0
num = random.randint(0,100)
if num >40:
zhuangzhe = Block(stone,cacti,bush)
block_list.add(zhuangzhe)
for prop in block_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(zhuangzhe.image, (zhuangzhe.rect.x, zhuangzhe.rect.y)) #screen.blit(zhuangzhe.image, (zhuangzhe.rect.x, zhuangzhe.rect.y))
pygame.display.update() pygame.display.update()
FPS.tick(60) FPS.tick(60)
......
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