Commit 347a5398 by BellCodeEditor

save project

parent e52d49cd
Showing with 16 additions and 7 deletions
......@@ -34,8 +34,9 @@ t = 30
road_x = 0
shan_x = 0
# +++++++++++++++++++++++
time = 0
obstacle = Block(bush,stone,cacti)
block_list = pygame.sprite.Group()
while True:
for event in pygame.event.get():
......@@ -79,12 +80,19 @@ while True:
screen.blit(road, (road_x, 500))
# _______________________________
screen.blit(wukong, (150, y)) # 悟空
if obstacle.rect.x <= 0-obstacle.rect.width: # 障碍物消失
# 创建障碍物对象
obstacle = Block(bush,stone,cacti)
obstacle.rect.x -= 8
screen.blit(obstacle.image, (obstacle.rect.x, obstacle.rect.y))
time = time + 1
if time >= 60:
r = random.randint(0,50)
if r > 40:
obstacle = Block(bush,stone,cacti)
block_list.add(obstacle)
time = 0
for a in block_list:
a.rect.x = a.rect.x - 8
screen.blit(a.image, (a.rect.x, a.rect.y))
if a.rect.x <= 0-a.rect.width:
a.kill()
# 刷新画面
pygame.display.update()
FPS.tick(30)
\ 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