Commit 2ec2d876 by BellCodeEditor

save project

parent 73d76535
Showing with 13 additions and 7 deletions
...@@ -81,19 +81,24 @@ while True: ...@@ -81,19 +81,24 @@ while True:
road_x = 0 road_x = 0
screen.blit(road,(road_x,500)) screen.blit(road,(road_x,500))
# 将背景图画上去 # 将背景图画上去
screen.blit(wukong, (150, y)) screen.blit(wukong.image, (150, y))
#screen.blit(obstacle,(rect.x,rect.y))
time += 1 time += 1
if time >= 60: if time >= 60:
time = 0 time = 0
num=random.randint(0,50)
if num>20:
obstacle = Block(bush,cacti,stone) obstacle = Block(bush,cacti,stone)
block_list.add(obstacle) block_list.add(obstacle)
for prop in block_list: for sprite in block_list:
prop.rect.x -= 8 sprite.rect.x -= 8
screen.blit(prop.image,(prop.rect.x,prop.rect.y)) screen.blit(sprite.image,(sprite.rect.x,sprite.rect.y))
if prop.rect.x<=0-prop.rect.width: if sprite.rect.x<=0-sprite.rect.width:
prop.kill() sprite.kill()
if pygame.sprite.collide_rect(wukong,sprite):
gameover = pygame.image.load('gameover.png')
screen.blit(gameover,(400,200))
gamestate = False
# 刷新画面 # 刷新画面
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