Commit ed98506d by BellCodeEditor

save project

parent b655e3a3
Showing with 8 additions and 15 deletions
...@@ -15,31 +15,24 @@ hero = [pygame.image.load("hero1.png"),pygame.image.load("hero2.png"),pygame.ima ...@@ -15,31 +15,24 @@ hero = [pygame.image.load("hero1.png"),pygame.image.load("hero2.png"),pygame.ima
index = 0 index = 0
junpingstate = "running" junpingstate = "running"
pygame.display.set_caption("悟空酷跑") pygame.display.set_caption("悟空酷跑")
y = 400
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:
# 接收到退出事件后退出程序 # 接收到退出事件后退出程序
exit() exit()
if event.type == locals.KEYDOWN: if event.type == locals.KEYDOWN:
if junpingstate == "running": if event.type == K.SPACE:
if event.type == locals.K_SPACE: junpingstate = "up"
junpingstate = "up"
if junpingstate == "up": if junpingstate == "up":
if t > 0: if y > 150:
y -= t y -= 5
t -= 2
else: else:
junpingstate = "down" junpingstate = "down"
if junpingstate == "down": if junpingstate == "down":
if t <= 300: if y < 400:
y += t y += 5
t += 2
else: else:
junpingstate = "running" junpingstate = "running"
t = 30
abc = hero[index] abc = hero[index]
index += 1 index += 1
if index >= 5: if index >= 5:
...@@ -50,4 +43,4 @@ while True: ...@@ -50,4 +43,4 @@ while True:
screen.blit(abc, (150, y)) screen.blit(abc, (150, y))
# 刷新画面 # 刷新画面
pygame.display.update() pygame.display.update()
FPS.tick(10) 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