Commit a397942d by BellCodeEditor

save project

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