Commit b6278a34 by BellCodeEditor

save project

parent 1908703f
Showing with 15 additions and 5 deletions
...@@ -12,7 +12,7 @@ class Block(pygame.sprite.Sprite): ...@@ -12,7 +12,7 @@ class Block(pygame.sprite.Sprite):
self.rect.y=500-self.rect.height self.rect.y=500-self.rect.height
screen = pygame.display.set_mode((1000, 600)) screen = pygame.display.set_mode((1000, 600))
FPS = pygame.time.Clock() # pygame时钟,控制游戏速度(帧数) FPS = pygame.time.Clock() # pygame时钟,控制游戏速度(帧数)
zaw_list=pygame.sprite.Group()
# 载入图片 # 载入图片
background = pygame.image.load('bg.png') # 背景 background = pygame.image.load('bg.png') # 背景
road = pygame.image.load('road.png') # 路 road = pygame.image.load('road.png') # 路
...@@ -35,7 +35,7 @@ y=400 ...@@ -35,7 +35,7 @@ y=400
#z=random.choice([stone,cacti,apple]) #z=random.choice([stone,cacti,apple])
#rect=stone.get_rect() #rect=stone.get_rect()
#z_x=1000 #z_x=1000
time=0
road_x=0 road_x=0
bg_x=0 bg_x=0
while True: while True:
...@@ -74,10 +74,20 @@ while True: ...@@ -74,10 +74,20 @@ while True:
#z_x-=8 #z_x-=8
road_x-=8 road_x-=8
bg_x-=1 bg_x-=1
if zaw.rect.x<= 0-zaw.rect.width: #if zaw.rect.x<= 0-zaw.rect.width:
time+=1
if time>=60:
time=0
num=random.randint(0,50)
if num>20:
zaw=Block(stone,cacti,apple) zaw=Block(stone,cacti,apple)
screen.blit(zaw.image, (zaw.rect.x, 500-zaw.rect.height)) zaw_list.add(zaw)
zaw.rect.x-=8 for i in zaw_list:
i.rect.x-=8
screen.blit(i.image, (i.rect.x, 500-i.rect.height))
if i.rect.x<=0-i.rect.width:
i.kill()
#z=random.choice([stone,cacti,apple]) #z=random.choice([stone,cacti,apple])
#rect=stone.get_rect() #rect=stone.get_rect()
#z_x=1000 #z_x=1000
......
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