Commit 4f6f6282 by BellCodeEditor

save project

parent c9218bf4
Showing with 8 additions and 14 deletions
...@@ -33,10 +33,7 @@ t = 30 ...@@ -33,10 +33,7 @@ t = 30
bg_x = 0 #背景x坐标 bg_x = 0 #背景x坐标
road_x = 0 #道路x坐标 road_x = 0 #道路x坐标
# +++++++++++++++++++++++ # +++++++++++++++++++++++
obstacle = random.choice([bush, stone, cacti]) obstacle=block(bush,cacti,stone)
rect = obstacle.get_rect()
rect.x = 1000
rect.y = 500 - rect.height
while True: while True:
for event in pygame.event.get(): for event in pygame.event.get():
...@@ -81,14 +78,11 @@ while True: ...@@ -81,14 +78,11 @@ while True:
# +++++++++++++++++++++++ # +++++++++++++++++++++++
screen.blit(wukong, (150, y)) # 悟空 screen.blit(wukong, (150, y)) # 悟空
if rect.x <= 0-rect.width: # 障碍物消失
# 创建障碍物对象 if obstacle.rect.x<=0-obstacle.rect.width:
obstacle = random.choice([bush,stone,cacti]) obstacle=block(bush,cacti,stone)
rect = obstacle.get_rect() obstacle.rect.x-=8
rect.x = 1000 screen.blit(obstacle.image, (obstacle.rect.x, obstacle.rect.y))
rect.y = 500 - rect.height
rect.x -= 8
screen.blit(obstacle, (rect.x, rect.y))
# 刷新画面 # 刷新画面
pygame.display.update() pygame.display.update()
FPS.tick(30) FPS.tick(60)
\ 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