Commit fb87f6c7 by BellCodeEditor

save project

parent e13bc487
Showing with 21 additions and 13 deletions
......@@ -17,17 +17,25 @@ hero = [pygame.image.load('hero1.png'),
pygame.image.load('hero3.png'),
pygame.image.load('hero4.png'),
pygame.image.load('hero5.png')]
abc = random.choice([bush,cacti,stone])
rect = abc.get_rect()
rect.x = 1000
rect.y = 500 - rect.height
class Block(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
abc = Block(bush,cacti,stone)
rect2 = road.get_rect()
rect2.x = 0
rect2.y = 500 - rect.height
rect2.y = 500 - abc.rect.height
rect3 = road.get_rect()
rect3.x = 0
index = 0
y = 400
mode = 0
g = 20
while True:
for event in pygame.event.get():
if event.type == locals.KEYDOWN:
......@@ -46,21 +54,21 @@ while True:
mode = 0
if mode == 0:
g = 20
screen.blit(background, (0, 0))
screen.blit(background, (rect3.x, 0))
screen.blit(road, (rect2.x, 500))
screen.blit(abc, (rect.x, rect.y))
screen.blit(abc.image, (abc.rect.x, abc.rect.y))
if mode == 0:
i += 1
screen.blit(hero[i % 5], (150, y))
if rect.x <= 0 - rect.width:
abc = random.choice([bush,cacti,stone])
rect = abc.get_rect()
rect.x = 1000
rect.y = 500 - rect.height
rect.x -= 10
if abc.rect.x <= 0 - abc.rect.width:
abc = Block(bush,cacti,stone)
abc.rect.x -= 10
if rect2.x <= -1000:
rect2.x = 0
rect2.x -= 10
if rect3.x <= -1000:
rect3.x = 0
rect3.x -= 2
pygame.display.set_caption('悟空酷跑')
# 刷新画面
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