Commit 747f783c by BellCodeEditor

auto save

parent 6ce30a94
Showing with 47 additions and 6 deletions
...@@ -19,20 +19,60 @@ hero=[pygame.image.load('hero1.png'), ...@@ -19,20 +19,60 @@ hero=[pygame.image.load('hero1.png'),
pygame.image.load('hero3.png'), pygame.image.load('hero3.png'),
pygame.image.load('hero4.png'), pygame.image.load('hero4.png'),
pygame.image.load('hero5.png')] # 1.1 pygame.image.load('hero5.png')] # 1.1
index = 0 index = 0 # 1.1
y = 400 # 1.2
t = 30 # 1.3
stone_x = 1000 # 1.4
jumpState = 'runing' # 1.2
while True: while True:
for event in pygame.event.get(): for event in pygame.event.get():
if event.type == locals.QUIT: if event.type == locals.QUIT:
# 接收到退出事件后退出程序 # 接收到退出事件后退出程序
exit() exit()
for i in range(5): #++++++++++++++++++++++++++++++
wukong=hero[i] if event.type == locals.KEYDOWN: # 1.2
i+=1 if jumpState=='runing': # 1.3
if event.key == locals.K_SPACE: # 1.2
jumpState = 'up' # 1.2
# if jumpState=='up': # 1.2
# if y>150:
# y-=5
# else:
# jumpState='down'
# if jumpState=='down':
# if y < 400:
# y+=5
# else:
# jumpState='runing' # 1.2
#++++++++++++++++++++++++++++++
if jumpState=='up': # 1.3
if t>0:
y-=t
t-=2
else:
jumpState='down'
if jumpState=='down':
if t<=30:
y+=t
t+=2
else:
jumpState='runing'
t = 30 # 1.3
#++++++++++++++++++++++++++++++
wukong = hero[index] # 1.1
if jumpState=='runing': # 1.3
index += 1 # 1.1
if index == 5: # 1.1
index = 0 # 1.1
#++++++++++++++++++++++++++++++
# 将背景图画上去 # 将背景图画上去
screen.blit(background, (0, 0)) screen.blit(background, (0, 0))
screen.blit(road, (0, 500)) screen.blit(road, (0, 500))
screen.blit(wukong, (150, 400)) #screen.blit(hero, (150, 400))
screen.blit(wukong, (150, 400)) # 1.1
screen.blit(wukong, (150, y)) # 1.2
# 刷新画面 # 刷新画面
stone_x -= 5 # 1.4
screen.blit(stone,(stone_x,400)) # 1.4
pygame.display.update() pygame.display.update()
FPS.tick(60) FPS.tick(60)
\ 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