Commit 0b1864e5 by BellCodeEditor

auto save

parent e1d04e01
Showing with 24 additions and 4 deletions
......@@ -18,23 +18,43 @@ hero = [pygame.image.load('hero1.png'),
pygame.image.load('hero5.png')]
index = 0
char_pic_index = 0
y=400
jumpState = "running"
speed = 30
while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
# 接收到退出事件后退出程序
exit()
char_pic_index = 0
if event.type == locals.KEYDOWN:
if event.key == locals.K_SPACE:
jumpState = "up"
if jumpState == "up":
if speed>0:
y-=speed
speed-=2.19
else:
jumpState = "down"
if jumpState == "down":
if speed<30:
y+=speed
speed+=1.93
else:
jumpState =="running"
speed =30
wukong = hero[char_pic_index]
# 将背景图画上去
screen.blit(background, (0, 0))
screen.blit(road, (0, 500))
screen.blit(hero, (150, 400))
screen.blit(wukong, (150, y))
char_pic_index+=1
if char_pic_index==5:
char_pic_index = 0
else:
char_pic_index+=1
# 刷新画面
pygame.display.update()
......
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