Commit c087d118 by BellCodeEditor

auto save

parent d11f9cb5
Showing with 11 additions and 3 deletions
...@@ -14,6 +14,7 @@ pygame.init() # 初始化 ...@@ -14,6 +14,7 @@ pygame.init() # 初始化
screen = pygame.display.set_mode((1000, 600)) screen = pygame.display.set_mode((1000, 600))
FPS = pygame.time.Clock() # pygame时钟,控制游戏速度(帧数) FPS = pygame.time.Clock() # pygame时钟,控制游戏速度(帧数)
pygame.display.set_caption("悟空酷跑") pygame.display.set_caption("悟空酷跑")
block_list = pygame.sprite.Group()
# 载入图片 # 载入图片
background = pygame.image.load('bg.png') # 背景 background = pygame.image.load('bg.png') # 背景
road = pygame.image.load('road.png') # 路 road = pygame.image.load('road.png') # 路
...@@ -76,12 +77,19 @@ while True: ...@@ -76,12 +77,19 @@ while True:
screen.blit(road, (road_x, 500)) # 路 screen.blit(road, (road_x, 500)) # 路
screen.blit(wukong, (150, y)) # 悟空 screen.blit(wukong, (150, y)) # 悟空
if things.rect.x <= 0-things.rect.width: # 障碍物消失 # if things.rect.x <= 0-things.rect.width: # 障碍物消失
# 创建障碍物对象 # # 创建障碍物对象
things = Block(bush,cacti,stone) # things = Block(bush,cacti,stone)
# things.rect.x -= 8
block_list.add(things.image)
for i in block_list:
if things.rect.x < 0 - things.rect.width:
things.rect.x -= 8 things.rect.x -= 8
screen.blit(things.image, (things.rect.x, things.rect.y)) screen.blit(things.image, (things.rect.x, things.rect.y))
# 刷新画面 # 刷新画面
pygame.display.update() pygame.display.update()
......
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