Commit a86bbf5f by BellCodeEditor

save project

parent 2742489a
Showing with 37 additions and 5 deletions
......@@ -9,6 +9,12 @@ class Block(pygame.sprite.Sprite):
self.rect=self.image.get_rect()
self.rect.x=1000
self.rect.y=500-self.rect.height
ciass player(pygame.sprite.Sprite)
def__init__(self,image):
super().__init__()
self.image=image
pygame.init() # 初始化
# 创建一个窗口
screen = pygame.display.set_mode((1000, 600))
......@@ -25,6 +31,15 @@ hero = [pygame.image.load('hero1.png'),
pygame.image.load('hero3.png'),
pygame.image.load('hero4.png'),
pygame.image.load('hero5.png')]
index=0
y=400
jumpState="runing"
t=30
road_x=0
bg_x=0
time=0
gamestate=True
biock_list=pygame.sprite.Group()
lu_x=0
shan_x=0
index = 0
......@@ -64,15 +79,32 @@ while True:
if index >= 5:
index = 0
# 将背景图画上去
shan_x -=2
if shan_x <-1000:
shan_x=0
screen.blit(background, (shan_x, 0)) # 远处背景
bg_x -=2
if bg_x <-1000:
bg_x=0
screen.blit(background, (bg_x, 0)) # 远处背景
lu_x -=8
if lu_x <-1000:
lu_x=0
screen.blit(road, (lu_x, 500)) # 路
screen.blit(wukong, (150, y)) # 悟空
screen.blit(wukong.image (150, y)) # 悟空
road_x-=8
if road_x<=-1000
road_x=0
time+=1
iftime>=60
time=0
num=random.randint(0,50)
if num>20
obstacle=Block(bush,cacti,stone)
Block_list.add(obstacle)
for sprite in biock_list:
sprite.rect.x-=8
screen.blit(sprite.rect.x,sprite)
if sprite.randint.x<=0
if aa.rect.x <= 0-aa.rect.width: # 障碍物消失
# 创建障碍物对象
......
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