Commit 56f8e85d by BellCodeEditor

save project

parent a9487c6f
Showing with 13 additions and 8 deletions
...@@ -11,6 +11,7 @@ class Block(pygame.sprite.Sprite): ...@@ -11,6 +11,7 @@ class Block(pygame.sprite.Sprite):
self.rect=self.image.get_rect() self.rect=self.image.get_rect()
self.rect.x=1000 self.rect.x=1000
self.rect.y=500-self.rect.height self.rect.y=500-self.rect.height
self.score=1
class Player(pygame.sprite.Sprite): class Player(pygame.sprite.Sprite):
def __init__(self,image): def __init__(self,image):
...@@ -24,7 +25,9 @@ screen = pygame.display.set_mode((1000, 600),pygame.RESIZABLE) ...@@ -24,7 +25,9 @@ screen = pygame.display.set_mode((1000, 600),pygame.RESIZABLE)
FPS = pygame.time.Clock() FPS = pygame.time.Clock()
pygame.display.set_caption('酷跑') pygame.display.set_caption('酷跑')
c=1
info='SCORES:' info='SCORES:'
score_music=pygame.mixer.Sound('score.wav')
word=pygame.font.Font('STKAITI.TTF',40) word=pygame.font.Font('STKAITI.TTF',40)
background = pygame.image.load('bg.png') # 背景 background = pygame.image.load('bg.png') # 背景
...@@ -104,11 +107,6 @@ while True: ...@@ -104,11 +107,6 @@ while True:
background_x-=2 background_x-=2
if background_x==-1000: if background_x==-1000:
background_x=0 background_x=0
nub1+=1
if nub1==50:
word2+=1
nub1=0
rectNub=word2
if word2/2==int(word2/2): if word2/2==int(word2/2):
nub=random.choice([1,2,3,4]) nub=random.choice([1,2,3,4])
...@@ -117,9 +115,8 @@ while True: ...@@ -117,9 +115,8 @@ while True:
screen.blit(background, (background_x, 0)) screen.blit(background, (background_x, 0))
screen.blit(road, (road_x,500)) screen.blit(road, (road_x,500))
screen.blit(wukong.image, (150,y)) screen.blit(wukong.image, (150,y))
scoreWord=word.render(info+str(word2),True,(255,255,255))
screen.blit(scoreWord, (730,10))
speed=8+word2//3
time+=1 time+=1
if time==50: if time==50:
time=0 time=0
...@@ -129,15 +126,23 @@ while True: ...@@ -129,15 +126,23 @@ while True:
block_list.add(o) block_list.add(o)
for prop in block_list: for prop in block_list:
prop.rect.x-=8 prop.rect.x-=speed
screen.blit(prop.image,(prop.rect.x,prop.rect.y)) screen.blit(prop.image,(prop.rect.x,prop.rect.y))
if pygame.sprite.collide_rect(wukong,prop): if pygame.sprite.collide_rect(wukong,prop):
gamestate=False gamestate=False
screen.blit(gameover,(500, 200)) screen.blit(gameover,(500, 200))
else:
if(prop.rect.x+prop.rect.width)<wukong.rect.x:
word2+=prop.score
prop.score=0
if prop.rect.x <= 0-prop.rect.width: if prop.rect.x <= 0-prop.rect.width:
prop.kill() prop.kill()
scoreWord=word.render(info+str(word2),True,(255,255,255))
screen.blit(scoreWord, (730,10))
pygame.mixer. mmznz
pygame.display.update() pygame.display.update()
FPS.tick(60) FPS.tick(60)
......
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