Commit eb0982e9 by BellCodeEditor

save project

parent 75a6126a
Showing with 27 additions and 6 deletions
......@@ -26,13 +26,16 @@ hero = [pygame.image.load('hero1.png'),
pygame.image.load('hero4.png'),
pygame.image.load('hero5.png')]
lu_x=0
num=0
shan_x=0
index = 0
y = 400
jumpState = "runing"
t = 30
aa=Block(bush,cacti,stone)
time=0
gamestate=True
aa_list=pygame.sprite.Group()
while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
......@@ -56,7 +59,12 @@ while True:
else:
jumpState = "runing"
t =30
if gamestate==True:
if jumpState =='up'
if t >0:
y-=t
wukong.rect.y=y
t-=2
# 悟空造型
wukong = hero[index]
if jumpState == "runing": # 跑步状态下
......@@ -74,12 +82,25 @@ while True:
screen.blit(road, (lu_x, 500)) # 路
screen.blit(wukong, (150, y)) # 悟空
if aa.rect.x <= 0-aa.rect.width: # 障碍物消失
#if aa.rect.x <= 0-aa.rect.width: # 障碍物消失
# 创建障碍物对象
time += 1
if time>=60:
time=0
num=random.randint(0,50)
if num>20:
aa=Block(bush,cacti,stone)
aa.rect.x -= 8
aa_list.add(aa)
for temp_sprit in aa_list:
temp_sprit.rect.x-=8
screen.blit(temp_sprit.image,(temp_sprit.rect.x,temp_sprit.rect.y))
if temp_sprit.rect.x <=0-temp_sprit.rect.width:
temp_sprit.kill()
if pygame.sprite.collide_rect(wukong,temp_sprit):
gameover=pygame.image.load()
screen.bilt(gameover,(400,200))
gamestate=False
time.sleep(1)
screen.blit(aa.image, (aa.rect.x, aa.rect.y))
# 刷新画面
pygame.display.update()
......
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