Commit bd299c82 by BellCodeEditor

save project

parent 1fde446e
Showing with 12 additions and 3 deletions
......@@ -10,7 +10,8 @@ class Block(pygame.sprite.Sprite):
self.rect=self.image.get_rect()
self.rect.x=1000
self.rect.y=500-self.rect.height
self.score=1
score=0
y=400
class Block2(pygame.sprite.Sprite):
def __init__(self,image):
......@@ -23,6 +24,8 @@ screen = pygame.display.set_mode((1000, 600))
FPS = pygame.time.Clock() # pygame时钟,控制游戏速度(帧数)
zaw_list=pygame.sprite.Group()
# 载入图片
font=pygame.font.Font('STKAITI.ttf',18)
background = pygame.image.load('bg.png') # 背景
road = pygame.image.load('road.png') # 路
stone = pygame.image.load('stone.png') # 石头
......@@ -86,7 +89,9 @@ while True:
screen.blit(wukong_1.image, (150, y))
#z_x-=8
road_x-=8
text=font.render('分数:'+str(score),True,(255,255,255))
screen.blit(text,(900,50))
road_x-=10
bg_x-=1
#if zaw.rect.x<= 0-zaw.rect.width:
time+=1
......@@ -97,7 +102,7 @@ while True:
zaw=Block(stone,cacti,apple)
zaw_list.add(zaw)
for i in zaw_list:
i.rect.x-=8
i.rect.x-=10
screen.blit(i.image, (i.rect.x, 500-i.rect.height))
if i.rect.x<=0-i.rect.width:
i.kill()
......@@ -105,6 +110,10 @@ while True:
gmover=pygame.image.load('gameover.png')
screen.blit(gmover,(400,250))
gameover=True
else:
if i.rect.x<wukong_1.rect.x:
score+=i.score
i.score=0
#z=random.choice([stone,cacti,apple])
#rect=stone.get_rect()
......
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