Commit ca10315b by BellCodeEditor

save project

parent eba81d69
Showing with 20 additions and 5 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:
...@@ -80,11 +81,25 @@ while True: ...@@ -80,11 +81,25 @@ while True:
# 将背景图画上去 # 将背景图画上去
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.rect.x -= 8
time += 1
if time >= 60:
time = 0
num = random.randint(0,100)
if num >40:
zhuangzhe = Block(stone,cacti,bush) zhuangzhe = Block(stone,cacti,bush)
zhuangzhe.rect.x -= 8 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