Commit 658cbc0e by BellCodeEditor

save project

parent eba02c72
Showing with 17 additions and 10 deletions
...@@ -32,7 +32,8 @@ jumpState = "runing" ...@@ -32,7 +32,8 @@ jumpState = "runing"
t = 30 t = 30
road_x = 0 road_x = 0
bg_x = 0 bg_x = 0
obstacle = Block(bush,stone,cacti) time = 0
block_list = pygame.sprite.Group()
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:
...@@ -55,7 +56,7 @@ while True: ...@@ -55,7 +56,7 @@ while True:
t += 2 t += 2
else: else:
jumpState = "runing" jumpState = "runing"
t =30 t = 30
# 悟空造型 # 悟空造型
wukong = hero[int(index)] wukong = hero[int(index)]
...@@ -67,18 +68,24 @@ while True: ...@@ -67,18 +68,24 @@ while True:
screen.blit(bg, (bg_x, 0)) # 远处背景 screen.blit(bg, (bg_x, 0)) # 远处背景
screen.blit(road, (road_x, 500)) # 路 screen.blit(road, (road_x, 500)) # 路
screen.blit(wukong, (150, y)) # 悟空 screen.blit(wukong, (150, y)) # 悟空
obstacle = Block(bush,stone,cacti)
if obstacle.rect.x <= 0 - obstacle.rect.width:
obstacle = Block(bush,stone,cacti)
obstacle.rect.x -= 8 block_list.add(obstacle)
for sprite in block_list:
sprite.rect.x -= 8
screen.blit(sprite.image,(sprite.rect.x,sprite.rect.y))
if sprite.rect.x <= 0 - sprite.rect.width :
sprite.kill()
# if obstacle.rect.x <= 0 - obstacle.rect.width:
# obstacle = Block(bush,stone,cacti)
# obstacle.rect.x -= 8
road_x -= 8 road_x -= 8
bg_x -= 2 bg_x -= 2
if road_x <= -1000: if road_x <= -1000:
road_x = 0 road_x = 0
if bg_x <= -1000: if bg_x <= -1000:
bg_x = 0 bg_x = 0
screen.blit(obstacle.image, (obstacle.rect.x, obstacle.rect.y)) # screen.blit(obstacle.image, (obstacle.rect.x, obstacle.rect.y))
# 刷新画面 # # 刷新画面
pygame.display.update() pygame.display.update()
FPS.tick(60) FPS.tick(500)
\ No newline at end of file \ 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