Commit 347a5398 by BellCodeEditor

save project

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