Commit 465907a6 by BellCodeEditor

save project

parent 7281c79f
Showing with 27 additions and 11 deletions
...@@ -22,9 +22,14 @@ zhuangtai = "running" ...@@ -22,9 +22,14 @@ zhuangtai = "running"
y = 400 y = 400
nu = 30 nu = 30
zhangai = random.choice([stone,cacti,bush]) zhangai = random.choice([stone,cacti,bush])
#创建列表,障碍
rect = zhangai.get_rect() rect = zhangai.get_rect()
rect_x = 1000 #获取障碍x,y
rect_y = 500 - rect.height rect.x = 1000
rect.y = 500 - rect.height
road_x=0
bg_x = 0
while True: while True:
for event in pygame.event.get(): for event in pygame.event.get():
...@@ -58,19 +63,30 @@ while True: ...@@ -58,19 +63,30 @@ while True:
if zhuangtai == "running": if zhuangtai == "running":
index += 1 index += 1
if index == 5: if index == 5:
index = 0 index = 0
bg_x -= 2
if bg_x <= -1000:
bg_x = 0
screen.blit(background, (bg_x, 0))
road_x -= 8
if road_x <= -1000:
road_x = 0
screen.blit(road, (road_x, 500))
# 将背景图画上去 # 将背景图画上去
screen.blit(background, (0, 0))
screen.blit(road, (0, 500))
screen.blit(wukong, (150, y)) screen.blit(wukong, (150, y))
# 刷新画面 # 刷新画面
if rect.x <= 0-rect.width: if rect.x <= 0-rect.width:
zhangai = random.choice([stone,cacti,bush]) zhangai = random.choice([stone,cacti,bush])
rect = zhangai.get_rect() rect = zhangai.get_rect()
rect_x = 1000 rect.x = 1000
rect_y = 500 - rect.height rect.y = 500 - rect.height
rect_x -= 8 rect.x -= 8
screen.blit(zhangai, (rect_x, rect_y)) screen.blit(zhangai, (rect.x, rect.y))
pygame.display.update() pygame.display.update()
FPS.tick(25) FPS.tick(25)
\ 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