Commit 089874c2 by BellCodeEditor

save project

parent 0aeda145
Showing with 26 additions and 21 deletions
...@@ -19,6 +19,7 @@ pygame.image.load('hero4.png'), ...@@ -19,6 +19,7 @@ pygame.image.load('hero4.png'),
pygame.image.load('hero5.png')] pygame.image.load('hero5.png')]
x = 0 x = 0
y=400 y=400
t=30
houer=hero[x] houer=hero[x]
action="go" action="go"
while True: while True:
...@@ -26,31 +27,35 @@ while True: ...@@ -26,31 +27,35 @@ while True:
if event.type == locals.QUIT: if event.type == locals.QUIT:
# 接收到退出事件后退出程序 # 接收到退出事件后退出程序
exit() exit()
if action=="go":
if event.type==locals.KEYDOWN:
if event.key==locals.K_SPACE:
action="up"
if action=="up":
if t > 0:
y-=t
t-=2
else:
action="down"
if action=="down":
if t <= 30:
y+=t
t+=2
else:
action="go"
t=30
if action=="go": if action=="go":
wukong = hero[x]
x+=1 x+=1
if x ==5: if x == 5:
x==0 x=0
if event.type==locals.KEYDOWN:
if event.key==locals.K_SPACE:
action="up"
if action=="up":
if y > 150:
y-=5
else:
action=="down"
if action=="down":
if y < 400:
y+=5
else:
action=="go"
# 将背景图画上去 # 将背景图画上去
screen.blit(background, (0, 0)) screen.blit(background, (0, 0))
screen.blit(road, (0, 500)) screen.blit(road, (0, 500))
screen.blit(houer, (150, y)) screen.blit(wukong, (150, y))
# 刷新画面 # 刷新画面
pygame.display.update() pygame.display.update()
FPS.tick(30) 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