Commit a39f9a31 by BellCodeEditor

save project

parent 749f661f
Showing with 9 additions and 4 deletions
......@@ -19,6 +19,7 @@ hero = [pygame.image.load('hero1.png'),
index = 0
State='running'
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'
t=30
......@@ -48,6 +52,7 @@ while True:
screen.blit(background, (0, 0))
screen.blit(road, (0, 500))
screen.blit(hero[index], (150, y))
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