Commit 7aebf5a9 by BellCodeEditor

save project

parent 7171029b
Showing with 18 additions and 6 deletions
......@@ -18,14 +18,19 @@ hero = [pygame.image.load('hero1.png'),
pygame.image.load('hero3.png'),
pygame.image.load('hero4.png'),
pygame.image.load('hero5.png')]
class Clock(pygame.sprite.Sprite):
def__init__(self,image1,image2,image3):
super().__init__()
self.image = random.choice([image1,image2,image3])
self.rect = self.image.get_rect()
self.rect.x = 1000
self.rect.y = 500 - self.rect.height
index = 0
y = 400
jumpState = "runing"
t = 30
obstacle = random.choice([bush, stone, cacti])
rect = obstacle.get_rect()
rect.x = 1000
rect.y = 500 - rect.height
bg_x = 0
road_x = 0
......@@ -70,14 +75,21 @@ while True:
if road_x<=-1000:
road_x = 0
screen.blit(road, (road_x, 500))
screen.blit(wukong, (150, y)) # 悟空
if rect.x <= 0-rect.width: # 障碍物消失
# 创建障碍物对象
obstacle = random.choice([bush,stone,cacti])
rect = obstacle.get_rect()
rect.x = 1000
rect.y = 500 - rect.height
if obstacle.rect.x <= 0-obstacle.rect.width:
obstacle = Clock(bush,cacti,stone)
obstacle.rect.x -= 8
screen.blit(obstacle.image,(obstacle.rect.x,obstacle.rect.y))
rect.x -= 8
screen.blit(obstacle, (rect.x, rect.y))
# 刷新画面
......
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