Commit 2ba12fe5 by BellCodeEditor

save project

parent e30a34a8
Showing with 16 additions and 8 deletions
...@@ -14,6 +14,7 @@ apple = pygame.image.load('bush.png') # 灌木丛 ...@@ -14,6 +14,7 @@ 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
jp="run" jp="run"
t = 30
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:
...@@ -21,18 +22,25 @@ while True: ...@@ -21,18 +22,25 @@ 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:
jp="up" if jp =="run":
jp="up"
if jp=="up": if jp=="up":
if y > 150: if t>0:
y -= 10 y -= t
t -=2
else: else:
jp="down" jp="down"
if jp == "down": if jp == "down":
if y < 400: if t<=30:
y += 10 y += t
index+=1 t +=2
if index > 4: else:
index = 0 jp="run"
t = 30
if jp =="run":
index+=1
if index > 4:
index = 0
# 将背景图画上去 # 将背景图画上去
screen.blit(background, (0, 0)) screen.blit(background, (0, 0))
screen.blit(road, (0, 500)) screen.blit(road, (0, 500))
......
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