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