Commit 3ffd9845 by BellCodeEditor

save project

parent 6858eede
Showing with 49 additions and 45 deletions
...@@ -35,6 +35,7 @@ road_x = 0 ...@@ -35,6 +35,7 @@ road_x = 0
aa=Block(bush,cacti,stone) aa=Block(bush,cacti,stone)
obstacle = Block(bush) obstacle = Block(bush)
time = 0 time = 0
True == 0
while True: while True:
for event in pygame.event.get(): for event in pygame.event.get():
...@@ -45,48 +46,51 @@ while True: ...@@ -45,48 +46,51 @@ while True:
if jumpState == "runing": if jumpState == "runing":
if event.key == locals.K_SPACE: if event.key == locals.K_SPACE:
jumpState = "up" jumpState = "up"
if gamestate == True:
if jumpState == "up": # 起跳状态 if jumpState == "up": # 起跳状态
if t > 0: if t > 0:
y -= t y -= t
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
t += 2 t += 2
else: else:
jumpState = "runing" jumpState = "runing"
t =30 t =30
# 悟空造型
wukong =Plaver(hero[index])
if jumpState == "runing": # 跑步状态下
index += 1
if index >= 5:
index = 0
# 将背景图画上去
road_x -=2
if road_x <-1000:
road_x=0
screen.blit(background, (road_x, 0)) # 远处背景
lu_x -=8
if lu_x <-1000:
lu_x=0
screen.blit(road, (lu_x, 500)) # 路
screen.blit(wukong, (150, y))
time += 1 # 悟空
# 障碍物消失
# 创建障碍物对象
obstacle=Block(bush,cacti,stone)
block_list.add(obstacle)
for sprite in block_list:
sprite.rect.x -= 8
screen.blit(sprite.tmage,(sprite.rect.x,sprite.rect.y))
if sprite.rect.x <= 0-sprite.rect.width:
sprite.kill()
if pygame.sprite.collide_rect(wukong,sprite):
gameover = pygame.image.load('gameover.png')
screen.blit(gameover,(400,200))
# 悟空造型 # 刷新画面
wukong = hero[index] pygame.display.update()
if jumpState == "runing": # 跑步状态下 FPS.tick(60)
index += 1 \ No newline at end of file
if index >= 5:
index = 0
# 将背景图画上去
road_x -=2
if road_x <-1000:
road_x=0
screen.blit(background, (road_x, 0)) # 远处背景
lu_x -=8
if lu_x <-1000:
lu_x=0
screen.blit(road, (lu_x, 500)) # 路
screen.blit(wukong, (150, y))
time += 1 # 悟空
# 障碍物消失
# 创建障碍物对象
obstacle=Block(bush,cacti,stone)
block_list.add(obstacle)
for sprite in block_list:
sprite.rect.x -= 8
screen.blit(sprite.tmage,(sprite.rect.x,sprite.rect.y))
if sprite.rect.x <= 0-sprite.rect.width:
sprite.kill()
# 刷新画面
pygame.display.update()
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