Commit b71c215b by BellCodeEditor

save project

parent a10e57ca
Showing with 18 additions and 12 deletions
...@@ -23,10 +23,10 @@ y = 400 ...@@ -23,10 +23,10 @@ y = 400
jumpState = "runing" jumpState = "runing"
t = 30 t = 30
road_x = 0 road_x = 0
obstacle = random.choice([bush, stone, cacti]) bg_x = 0
rect = obstacle.get_rect() time = 0
rect.x = 1000
rect.y = 500 - rect.height block_list = pygame.sprite.Group()
while True: while True:
for event in pygame.event.get(): for event in pygame.event.get():
...@@ -67,14 +67,19 @@ while True: ...@@ -67,14 +67,19 @@ while True:
# 路 # 路
screen.blit(wukong, (150, y)) # 悟空 screen.blit(wukong, (150, y)) # 悟空
if rect.x <= 0-rect.width: # 障碍物消失 time += 1
# 创建障碍物对象 if time >= 60:
obstacle = random.choice([bush,stone,cacti]) time = 0
rect = obstacle.get_rect() num = random.randint(0,50)
rect.x = 1000 if num > 20:
rect.y = 500 - rect.height obstacle = Block(bush,cacti,stone)
rect.x -= 8 block_list.add(obstacle)
screen.blit(obstacle, (rect.x, rect.y)) for sprite in block_list:
sprite.rect.x -= 8
scree.blit(sprite.image,(sprite.rect.x,sprite.rect.y))
if sprite.rect.x <= 0-sprite.rect.width:
sprite.kill()
# 刷新画面 # 刷新画面
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