Commit a397942d by BellCodeEditor

save project

parent 835a0e50
Showing with 9 additions and 22 deletions
......@@ -20,7 +20,7 @@ background = pygame.image.load('bg.png') # 背景
road = pygame.image.load('road.png') # 路
stone = pygame.image.load('stone.png') # 石头
cacti = pygame.image.load('cacti.png') # 仙人掌
bush = pygame.image.load('bush.png')# 灌木丛
bush = pygame.image.load('bush.png') # 灌木丛
hero = [pygame.image.load('hero1.png'),
pygame.image.load('hero2.png'),
pygame.image.load('hero3.png'),
......@@ -31,12 +31,10 @@ y = 400
jumpState = "runing"
t = 30
#++++++++++++++++++++++++++++++
#zhangai = Block(bush, stone, cacti)
zhangai = Block(bush, stone, cacti)
#++++++++++++++++++++++++++++++
road_x=0
bg_x=0
block_list=pygame.sprite.Group()
time=0
while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
......@@ -80,24 +78,12 @@ while True:
#++++++++++++++++++++++++++++
screen.blit(wukong, (150, y)) # 悟空
#+++++++++++++++++++++++++++++++++++++++
# if zhangai.rect.x <= 0-zhangai.rect.width: # 障碍物消失
# # 创建障碍物对象
# zhangai = Block(bush, stone, cacti)
# zhangai.rect.x-= 8
# screen.blit(zhangai.image, (zhangai.rect.x, zhangai.rect.y))
#++++++++++++++++++++++++++++++
time+=1
if time>=60:
time=0
num=random.randint(0,50)
if num>20:
zhangai = Block(bush,stone,cacti)
block_list.add(zhangai)
for prop in block_list:
prop.rect.x-=8
screen.blit(prop.image,(prop.rect.x,prop.rect.y))
if prop.rect.x <= 0-prop.rect.width:
prop.kill()
if zhangai.rect.x <= 0-zhangai.rect.width: # 障碍物消失
# 创建障碍物对象
zhangai = Block(bush, stone, cacti)
zhangai.rect.x-= 8
screen.blit(zhangai.image, (zhangai.rect.x, zhangai.rect.y))
# 刷新画面
pygame.display.update()
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