Commit 14ee5012 by BellCodeEditor

save project

parent 3dc8ec7e
Showing with 14 additions and 9 deletions
...@@ -18,6 +18,7 @@ hero = [pygame.image.load('hero1.png'), ...@@ -18,6 +18,7 @@ hero = [pygame.image.load('hero1.png'),
pygame.image.load('hero5.png')] pygame.image.load('hero5.png')]
index = 0 index = 0
y = 400 y = 400
t = 30
seat = 'running' seat = 'running'
while True: while True:
for event in pygame.event.get(): for event in pygame.event.get():
...@@ -26,21 +27,25 @@ while True: ...@@ -26,21 +27,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:
seat = 'up' if seat == 'running':
seat = 'up'
if seat == 'up': if seat == 'up':
if y > 150: if t > 0:
y -= 5 y -= t
t -= 2
else: else:
seat = 'down' seat = 'down'
if seat == 'down': if seat == 'down':
if y < 400: if t <= 30:
y += 5 y += t
t += 2
else: else:
seat = 'running' seat = 'running'
t = 30
# 将背景图画上去 # 将背景图画上去
wukong = hero[index] wukong = hero[index]
index += 1 if seat == 'running':
index += 1
if index >= 5: if index >= 5:
index = 0 index = 0
screen.blit(background, (0, 0)) screen.blit(background, (0, 0))
...@@ -48,4 +53,4 @@ while True: ...@@ -48,4 +53,4 @@ while True:
screen.blit(wukong, (150, y)) screen.blit(wukong, (150, y))
# 刷新画面 # 刷新画面
pygame.display.update() pygame.display.update()
FPS.tick(60) FPS.tick(30)
\ 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