Commit a39f9a31 by BellCodeEditor

save project

parent 749f661f
Showing with 12 additions and 7 deletions
......@@ -18,7 +18,8 @@ hero = [pygame.image.load('hero1.png'),
pygame.image.load('hero5.png')]
index = 0
State='running'
y=400
y=400
t=30
while True:
for event in pygame.event.get():
......@@ -26,18 +27,21 @@ while True:
# 接收到退出事件后退出程序
exit()
if event.type==locals.KEYDOWN:
if event.key==locals.K_SPACE:
if event.key==locals.K_SPACE and State=='running':
State='up'
if State=='up':
if y>150:
y-=10
if t>0:
y-=t
t-=2
else:
State='down'
if State=='down':
if y<400:
y+=10
y+=t
t+=2
else:
State='running'
State='running'
t=30
......@@ -48,7 +52,8 @@ while True:
screen.blit(background, (0, 0))
screen.blit(road, (0, 500))
screen.blit(hero[index], (150, y))
index+=1
if State=='running':
index+=1
if index>len(hero)-1:
index=0
# 刷新画面
......
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