Commit c0cf0460 by BellCodeEditor

save project

parent df57f357
Showing with 11 additions and 6 deletions
......@@ -13,6 +13,7 @@ cacti = pygame.image.load('cacti.png') # 仙人掌
apple = pygame.image.load('bush.png') # 灌木丛
hero = [pygame.image.load('hero1.png'),pygame.image.load('hero2.png'),pygame.image.load('hero3.png'),pygame.image.load('hero4.png'),pygame.image.load('hero5.png')]
index = 0
speed=30
sport="running"
pygame.display.set_caption("悟空酷跑")
while True:
......@@ -22,19 +23,23 @@ while True:
exit()
if event.type==locals.KEYDOWN:
if event.key==locals.K_SPACE:
if sport !="up"and sport!= 'down':
sport="up"
if sport=="up":
if y>150:
y-=5
if speed>0:
y-=speed
speed -= 2
else:
sport="down"
if sport=="down":
if y<400:
y+=5
if speed<30:
speed+=2
y += speed
else:
sport="running"
speed=30
if sport == 'running':
index+=1
if index >=len(hero):
index=0
......
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