Commit 97450661 by BellCodeEditor

save project

parent bd299c82
Showing with 13 additions and 4 deletions
......@@ -12,6 +12,8 @@ class Block(pygame.sprite.Sprite):
self.rect.y=500-self.rect.height
self.score=1
score=0
old_score=0
speed=10
y=400
class Block2(pygame.sprite.Sprite):
def __init__(self,image):
......@@ -36,6 +38,7 @@ hero = [pygame.image.load('hero1.png'),
pygame.image.load('hero3.png'),
pygame.image.load('hero4.png'),
pygame.image.load('hero5.png')]
get_score=pygame.mixer.Sound('score.wav')
index = 0
pygame.display.set_caption('悟空酷跑')
a=0
......@@ -90,19 +93,19 @@ while True:
#z_x-=8
text=font.render('分数:'+str(score),True,(255,255,255))
screen.blit(text,(900,50))
road_x-=10
screen.blit(text,(880,20))
road_x-=speed
bg_x-=1
#if zaw.rect.x<= 0-zaw.rect.width:
time+=1
if time>=60:
time=0
num=random.randint(0,50)
num=random.randint(1,50)
if num>20:
zaw=Block(stone,cacti,apple)
zaw_list.add(zaw)
for i in zaw_list:
i.rect.x-=10
i.rect.x-=speed
screen.blit(i.image, (i.rect.x, 500-i.rect.height))
if i.rect.x<=0-i.rect.width:
i.kill()
......@@ -118,11 +121,16 @@ while True:
#z=random.choice([stone,cacti,apple])
#rect=stone.get_rect()
#z_x=1000
if score>old_score:
get_score.play()
old_score=score
if road_x<-1000:
road_x=0
if bg_x<-1000:
bg_x=0
speed=10+score//2
# 刷新画面
pygame.display.update()
FPS.tick(60)
\ No newline at end of file
File added
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