Commit fa50ce17 by BellCodeEditor

save project

parent 945eeb29
Showing with 19 additions and 6 deletions
...@@ -42,6 +42,7 @@ aa=Block(bush,cacti,stone) ...@@ -42,6 +42,7 @@ aa=Block(bush,cacti,stone)
Block_list=pygame.sprite.Group() Block_list=pygame.sprite.Group()
time=0 time=0
b=0 b=0
gamestate=True
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:
...@@ -51,27 +52,34 @@ while True: ...@@ -51,27 +52,34 @@ while True:
if jumpState == "runing": if jumpState == "runing":
if event.key == locals.K_SPACE: if event.key == locals.K_SPACE:
jumpState = "up" jumpState = "up"
wukong = wu(hero[index])
if jumpState == "runing": # 跑步状态下
index += 1
if index >= 5:
index = 0
if gamestate==True:
if jumpState == "up": # 起跳状态 if jumpState == "up": # 起跳状态
if t > 0: if t > 0:
y -= t y -= t
wukong.rect.y=y
t -= 2 t -= 2
else: else:
jumpState = "down" jumpState = "down"
if jumpState == "down": # 降落状态 if jumpState == "down": # 降落状态
if t <= 30: if t <= 30:
y += t y += t
wukong.rect.y=y
t += 2 t += 2
else: else:
jumpState = "runing" jumpState = "runing"
t =30 t =30
# 悟空造型 # 悟空造型
wukong = wu(hero[index]) # wukong = wu(hero[index])
if jumpState == "runing": # 跑步状态下 # if jumpState == "runing": # 跑步状态下
index += 1 # index += 1
if index >= 5: # if index >= 5:
index = 0 # index = 0
#if aa.rect.x<=0-aa.rect.width: #if aa.rect.x<=0-aa.rect.width:
#aa=Block(bush,cacti,stone) #aa=Block(bush,cacti,stone)
#aa.rect.x-=8 #aa.rect.x-=8
...@@ -99,6 +107,7 @@ while True: ...@@ -99,6 +107,7 @@ while True:
screen.blit(background, (shan_x,0)) screen.blit(background, (shan_x,0))
screen.blit(road, (lu_x, 500)) # 路 screen.blit(road, (lu_x, 500)) # 路
screen.blit(wukong.image, (wukong.rect.x,y)) # 悟空 screen.blit(wukong.image, (wukong.rect.x,y)) # 悟空
...@@ -107,6 +116,10 @@ while True: ...@@ -107,6 +116,10 @@ while True:
screen.blit(c.image, (c.rect.x, c.rect.y)) screen.blit(c.image, (c.rect.x, c.rect.y))
if c.rect.x<=0-c.rect.width: if c.rect.x<=0-c.rect.width:
c.kill() c.kill()
if pygame.sprite.collide_rect(wukong,c):
gameover=pygame.image.load('gameover.png')
screen.blit(gameover,(400,200))
gamestate=False
......
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