Commit b124ff49 by BellCodeEditor

auto save

parent 30a85027
Showing with 20 additions and 17 deletions
...@@ -24,30 +24,33 @@ index = 0 ...@@ -24,30 +24,33 @@ index = 0
#设置悟空的y坐标 #设置悟空的y坐标
y=400 y=400
jumpstate="running" jumpstate="running"
t=30
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()
#判断事件类型是否为按键按下 if event.type==locals.KEYDOWN:#判断事件类型是否为按键按下
#判断是否按下空格键K_SPACE if event.key==locals.K_SPACE:#判断是否按下空格键K_SPACE
#把悟空的状态修改为起跳up jumpstate='up'#把悟空的状态修改为起跳up
#判断悟空是否在起跳 if jumpstate=='up':#判断悟空是否在起跳
#判断悟空的y坐标是否大于150 if t>0:#判断悟空的y坐标是否大于150
#向上移动 y-=t#向上移动
#否则 t-=2
#把悟空的状态改为down else:#否则
##判断悟空是否为下落状态 jumpstate='down'#把悟空的状态改为down
#判断悟空的y坐标是否小于400 if jumpstate=='down':##判断悟空是否为下落状态
#向下移动 if t<=30:#判断悟空的y坐标是否小于400
#否则 y+=t#向下移动
#把悟空改为跑步状态 t+=2
else:#否则
jumpstate='running'#把悟空改为跑步状态
wukong=hero[index]#设置悟空初始造型wukong wukong=hero[index]#设置悟空初始造型wukong
index+=1#切换下一个造型 if jumpstate=='running':
if index==5:#判断索引是否为5 index+=1#切换下一个造型
index=0#索引设为0 if index==5:#判断索引是否为5
index=0#索引设为0
# 将背景图画上去 # 将背景图画上去
screen.blit(background, (0, 0)) screen.blit(background, (0, 0))
screen.blit(road, (0, 500)) screen.blit(road, (0, 500))
......
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