Commit 894324b3 by BellCodeEditor

save project

parent 002a652e
Showing with 16 additions and 1 deletions
...@@ -16,18 +16,33 @@ hero = [pygame.image.load("hero1.png"), ...@@ -16,18 +16,33 @@ hero = [pygame.image.load("hero1.png"),
pygame.image.load("hero4.png"), pygame.image.load("hero4.png"),
pygame.image.load("hero5.png")] pygame.image.load("hero5.png")]
index = 0 index = 0
jumpstate = "running"
y = 400
FPS = pygame.time.Clock() FPS = pygame.time.Clock()
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:
exit() exit()
if event.type == locals.KEYDOWN:
if event.key == locals.K_SPACE:
jumpstate = "up"
caozibo = hero[index] caozibo = hero[index]
index += 1 index += 1
if index>4: if index>4:
index=0 index=0
if jumpstate == "up":
if y>150:
y -= 5
else:
jumpstate = "down"
elif jumpstate == "down":
if y<400:
y += 5
else:
jumpstate = "running"
screen.blit(bg,(0,0)) screen.blit(bg,(0,0))
screen.blit(road,(0,500)) screen.blit(road,(0,500))
screen.blit(caozibo,(150,400)) screen.blit(caozibo,(150,y))
pygame.display.update() pygame.display.update()
FPS.tick(60) FPS.tick(60)
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