Commit 935d0563 by BellCodeEditor

save project

parent b6582f26
Showing with 17 additions and 2 deletions
......@@ -14,18 +14,33 @@ apple = pygame.image.load('bush.png') # 灌木丛
hero = pygame.image.load('hero1.png')
index = 0
num = 0
jumpState = 'running'
herolist = ['hero1.png','hero2.png','hero3.png','hero4.png','hero5.png']
y = 400
while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
# 接收到退出事件后退出程序
exit()
if event.type == locals.KEYDOWN:
if event.key == locals.K_SPACE and jumpState != 'up':
jumpState = "up"
if jumpState == "up": # 起跳
if y > 150:
y -= 40
else:
jumpState = "down"
if jumpState == "down": # 起跳
if y < 400:
y += 40
else:
jumpState = "running"
# 将背景图画上去
screen.blit(background, (0, 0))
screen.blit(road, (0, 500))
screen.blit(hero, (150, 400))
screen.blit(hero, (150, y))
# 跑步效果
hero = pygame.image.load(herolist[num])
num += 1
......
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