Commit ce6ffa7d by BellCodeEditor

auto save

parent 6c067fcc
Showing with 20 additions and 13 deletions
......@@ -44,8 +44,10 @@ obstacle = random.choice([stone,cacti,bush])
rect= obstacle.get_rect() #获取图片的坐标和长宽属性
rect.x=1000
rect.y=500-rect.height
time = 0
obstacle=Block(bush,cacti,stone)
block_list=pygame.sprite.Group()#创建精灵组
while True:
......@@ -66,7 +68,7 @@ while True:
if jumpState == "down": # 降落
if t <= 30:
y += t
t += 0.00000002
t += 2
else:
jumpState = "running"
......@@ -78,23 +80,28 @@ while True:
index+=1
if index==5:
index=0
# 将背景图画上去
screen.blit(background, (0, 0))
screen.blit(road, (0, 500))
screen.blit(wukong, (150, y))
#一个障碍物消失后,在添加一个新的障碍物
if rect.x<=0-rect.width:
obstacle=random.choice(zaw)
rect=obstacle.get_rect()
rect.x=1000
rect.y=500-rect.width
rect.x-=8
screen.blit(obstacle,(rect.x,rect.y))
time += 1
if time >= 60:
time = 0
num = random.randint(0,50)
if num > 20:
obstacle=Block(bush,cacti,stone)#创建障碍物精灵
block_list.add(obstacle)
for sprite in block_list:
sprite.rect.x -=8
screen.blit(sprite.image,(sprite.rect.x,sprite.rect.y))
if sprite.rect.x <= 0-sprite.rect.width:
sprite.kill()
# 刷新画面
pygame.display.update()
......
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