Commit 33e37399 by BellCodeEditor

auto save

parent 20a9dd33
Showing with 12 additions and 9 deletions
......@@ -23,9 +23,7 @@ y = 400
jumpState = "runing"
t = 30
road_x=0
image_list = [bush, stone, cacti]
cd=0
obstacle_list = [bush, stone, cacti]
class Block():
def __init__(self,list):
......@@ -34,7 +32,7 @@ class Block():
self.rect=self.image.get_rect()
self.rect.x=1000
self.rect.y=500-self.rect.height
obstacle_list=pygame.sprite.Group()
obstacle=Block(obstacle_list)
while True:
for event in pygame.event.get():
......@@ -70,11 +68,15 @@ while True:
screen.blit(background, (0, 0)) # 远处背景
screen.blit(road, (road_x, 500)) # 路
screen.blit(wukong, (150, y)) # 悟空
if cd==30:
r=random.randint(0,100)
if r>60:
obstacle=Block(image_list)
obstacle_list.add(obstacle)
if obstacle.rect.x <= 0-obstacle.rect.width: # 障碍物消失
# 创建障碍物对象
obstacle=Block(obstacle_list)
obstacle.rect.x -= 8
road_x -= 8
if road_x<=-1000:
road_x=0
screen.blit(obstacle.image,(obstacle.rect.x, obstacle.rect.y))
# 刷新画面
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