Commit 244788e0 by BellCodeEditor

save project

parent 040df244
Showing with 10 additions and 6 deletions
...@@ -15,6 +15,7 @@ hero = pygame.image.load('hero1.png') ...@@ -15,6 +15,7 @@ hero = pygame.image.load('hero1.png')
index = 0 index = 0
num = 0 num = 0
jumpState = 'running' jumpState = 'running'
t = 30
herolist = ['hero1.png','hero2.png','hero3.png','hero4.png','hero5.png'] herolist = ['hero1.png','hero2.png','hero3.png','hero4.png','hero5.png']
y = 400 y = 400
while True: while True:
...@@ -26,16 +27,19 @@ while True: ...@@ -26,16 +27,19 @@ while True:
if event.key == locals.K_SPACE and jumpState == 'running': if event.key == locals.K_SPACE and jumpState == 'running':
jumpState = "up" jumpState = "up"
if jumpState == "up": # 起跳 if jumpState == "up": # 起跳
if y > 150: if t > 0:
y -= 40 y -= t
t -= 2
else: else:
jumpState = "down" jumpState = "down"
if jumpState == "down": # 起跳 if jumpState == "down": # 起跳
if y < 400: if t <= 30:
y += 40 y += t
t += 2
else: else:
jumpState = "running" jumpState = "running"
t = 30
# 将背景图画上去 # 将背景图画上去
screen.blit(background, (0, 0)) screen.blit(background, (0, 0))
...@@ -48,4 +52,4 @@ while True: ...@@ -48,4 +52,4 @@ while True:
num = 0 num = 0
# 刷新画面 # 刷新画面
pygame.display.update() pygame.display.update()
FPS.tick(20) FPS.tick(60)
\ No newline at end of file \ 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