Commit b01615b4 by BellCodeEditor

save project

parent 3ea21a03
Showing with 14 additions and 10 deletions
...@@ -32,6 +32,7 @@ t = 30 ...@@ -32,6 +32,7 @@ t = 30
road_x=0 road_x=0
bg_x=0 bg_x=0
obstacle = block.([bush, stone, cacti]) obstacle = block.([bush, stone, cacti])
block_list=pygame.spri.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:
...@@ -74,16 +75,18 @@ while True: ...@@ -74,16 +75,18 @@ while True:
# 远处背景 # 远处背景
screen.blit(road, (0, 500)) # 路 screen.blit(road, (0, 500)) # 路
screen.blit(wukong, (150, y)) # 悟空 screen.blit(wukong, (150, y)) # 悟空
time+=1
if time >=60:
r = random.randint(0,100)
if r >40:
obstacle=block(bush,cacti,stone)
if obstacle. rect.x <= 0-bostacle.rect.width: # 障碍物消失 block_list.add(obstacle)
# 创建障碍物对象 time=0
obstacle = block.([bush,stone,cacti]) for sprite in block_list:
obstacle.rect.x-=8 sprite.rect.x-=8
screen.blit(obstacle,image, (obstacle,rect.x, rect.y)) screen.blit.x(sprite.image,(sprite,rect,x,prop.rect.y))
if sprite.rect.x<=0-sprite.rect.width
sprite.kill()
# 刷新画面 # 刷新画面
pygame.display.update() pygame.display.update()
FPS.tick(60) 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