Commit 4bb4f5aa by BellCodeEditor

save project

parent f9cff980
Showing with 7 additions and 6 deletions
...@@ -19,12 +19,13 @@ hero = [pygame.image.load('hero1.png'), ...@@ -19,12 +19,13 @@ 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')] pygame.image.load('hero5.png')]
#变量初始化
lu_x=0 lu_x=0
shan_x=0 shan_x=0
index = 0 index = 0
y = 400 y = 400
jumpState = "runing" jumpState = "runing"
t = 60 t = 37
zhangaiwu=choice([bush,cacti,stone])#随机获得一个障碍物 zhangaiwu=choice([bush,cacti,stone])#随机获得一个障碍物
xingzhuang=zhangaiwu.get_rect()#活得障碍物的坐标,宽,高。 xingzhuang=zhangaiwu.get_rect()#活得障碍物的坐标,宽,高。
xingzhuang.x=1000#使障碍物的x坐标为1000 xingzhuang.x=1000#使障碍物的x坐标为1000
...@@ -35,7 +36,7 @@ while True: ...@@ -35,7 +36,7 @@ while True:
# 接收到退出事件后退出程序 # 接收到退出事件后退出程序
exit() exit()
if event.type == locals.KEYDOWN: if event.type == locals.KEYDOWN:
if jumpState == "runing": if jumpState == "running":
if event.key == locals.K_SPACE: if event.key == locals.K_SPACE:
jumpState = "up" jumpState = "up"
...@@ -46,16 +47,16 @@ while True: ...@@ -46,16 +47,16 @@ while True:
else: else:
jumpState = "down" jumpState = "down"
if jumpState == "down": # 降落状态 if jumpState == "down": # 降落状态
if t <= 60: if t <= 37:
y += t y += t
t += 2 t += 2
else: else:
jumpState = "runing" jumpState = "running"
t =60 t =37
# 悟空造型 # 悟空造型
wukong = hero[index] wukong = hero[index]
if jumpState == "runing": # 跑步状态下 if jumpState == "running": # 跑步状态下
index += 1 index += 1
if index >= 5: if index >= 5:
index = 0 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