Commit 85562083 by BellCodeEditor

save project

parent 16d35c29
Showing with 23 additions and 28 deletions
...@@ -17,47 +17,42 @@ hero = [pygame.image.load('hero1.png'), ...@@ -17,47 +17,42 @@ hero = [pygame.image.load('hero1.png'),
pygame.image.load('hero3.png'), pygame.image.load('hero3.png'),
pygame.image.load('hero4.png'), pygame.image.load('hero4.png'),
pygame.image.load('hero5.png')] pygame.image.load('hero5.png')]
y=400 y=400
index = 0 index = 0
z='r' z='r'
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 event.key == locals.K_SPACE: if z=='r':
z='u' if event.key == locals.K_SPACE:
z='u'
if z=='u':
if y>150:
y-=0.01
else:
z='d'
if z=='d':
if y<400:
y+=0.01
else:
z='r'
wukong=hero[index] wukong=hero[index]
index+=1 index+=1
if index == 5: if index == 5:
index=1 index=1
if z=='u'or z=='d':
index=1
if z == 'u':
if t>0:
y-=t
t-=2
else:
z='d'
if z=='d':
if t<=30:
y+=t
t+=2
else:
z='d'
t=30
# 将背景图画上去 # 将背景图画上去
screen.blit(background, (0, 0)) screen.blit(background, (0, 0))
...@@ -65,4 +60,4 @@ while True: ...@@ -65,4 +60,4 @@ while True:
screen.blit(wukong, (150, y)) screen.blit(wukong, (150, y))
# 刷新画面 # 刷新画面
pygame.display.update() pygame.display.update()
FPS.tick(200000000000000000000000) FPS.tick(99)
\ 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