Commit baaa4623 by BellCodeEditor

save project

parent ba465ce1
Showing with 7 additions and 5 deletions
......@@ -5,10 +5,10 @@ import random
class Block(pygame.sprite.Sprite):
def __init__(self,image1,image2,image3):
super().__init__()
self.image = random.choice([bush, stone, cacti])
self.rect = self.image.get_rect
self.image = random.choice([image1,image2,image3])
self.rect = self.image.get_rect()
self.rect.x = 1000
self.rect.y = 500 - rect.height
self.rect.y = 500 - self.rect.height
# 创建一个窗口
screen = pygame.display.set_mode((1000, 600))
......@@ -31,6 +31,7 @@ jumpState = "runing"
t = 30
road_x = 0
background_x = 0
obstacle = Block(stone,cacti,bush)
while True:
......@@ -76,9 +77,9 @@ while True:
if obstacle.rect.x <= 0-obstacle.rect.width: # 障碍物消失
# 创建障碍物对象
obstacle = Block([stone,cacti,bush])
obstacle = Block(stone,cacti,bush)
obstacle.rect.x -= 8
screen.blit(obstacle.image, (rect.x, rect.y))
screen.blit(obstacle.image, (obstacle.rect.x, obstacle.rect.y))
# 刷新画面
pygame.display.update()
FPS.tick(45)
\ 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