Commit 91f6a5b4 by BellCodeEditor

save project

parent a85ebfc5
Showing with 15 additions and 7 deletions
...@@ -18,6 +18,7 @@ hero = [pygame.image.load("hero1.png"), ...@@ -18,6 +18,7 @@ hero = [pygame.image.load("hero1.png"),
index = 0 index = 0
jumpstate = "running" jumpstate = "running"
y = 400 y = 400
t = 30
FPS = pygame.time.Clock() FPS = pygame.time.Clock()
while True: while True:
for event in pygame.event.get(): for event in pygame.event.get():
...@@ -25,21 +26,28 @@ while True: ...@@ -25,21 +26,28 @@ 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:
jumpstate = "up" if jumpstate == "running":
jumpstate = "up"
caozibo = hero[index] caozibo = hero[index]
index += 1 if jumpstate == "running":
index += 1
if index>4: if index>4:
index=0 index=0
if jumpstate == "up": if jumpstate == "up":
if y>150: if t>0:
y -= 5 y-=t
t -= 2
else: else:
jumpstate = "down" jumpstate = "down"
elif jumpstate == "down": elif jumpstate == "down":
if y<400: if t<=30:
y += 5 y+=t
t += 2
else: else:
jumpstate = "running" jumpstate = "running"
t=30
screen.blit(bg,(0,0)) screen.blit(bg,(0,0))
screen.blit(road,(0,500)) screen.blit(road,(0,500))
screen.blit(caozibo,(150,y)) screen.blit(caozibo,(150,y))
......
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