Commit d876d15a by BellCodeEditor

save project

parent 9b7a8e32
Showing with 13 additions and 6 deletions
......@@ -20,7 +20,9 @@ hero = [pygame.image.load('hero1.png'),
number = 0
y = 400
t = 30
score = 0
new_score = 0
old_score = 0
score_music = pygame.mixer.Sound('score.wav')
sss = pygame.font.Font('STKAITI.TTF',20)
class Block(pygame.sprite.Sprite):
def __init__(self,image1,image2,image3):
......@@ -46,6 +48,8 @@ t = 30
time = 0
changex = 0
gamestate = True
speed = 8
while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
......@@ -55,6 +59,7 @@ while True:
if jumpState == "runing":
if event.key == locals.K_SPACE:
jumpState = "up"
speed=speed+new_score//30 # 加速
wukong = Player(hero[index])
if jumpState == "runing": # 跑步状态下
index += 1
......@@ -79,7 +84,7 @@ while True:
if changex<=-1000:# 路的移动
changex = 0
else:
changex-=8
changex-=speed
# 悟空造型
# 将背图画上去
time+=1
......@@ -95,7 +100,7 @@ while True:
for sprite in group:
screen.blit(sprite.image, (sprite.rect.x, sprite.rect.y))
sprite.rect.x-=8
sprite.rect.x-=speed
if sprite.rect.x <= 0-sprite.rect.width: # 障碍物消失
sprite.kill()
if pygame.sprite.collide_rect(wukong,sprite):
......@@ -104,10 +109,12 @@ while True:
gamestate = False
else:
if sprite.rect.x+sprite.rect.width<wukong.rect.x:
score+=sprite.score
new_score+=sprite.score
sprite.score=0
text=sss.render('SCORE:'+str(score),True,(0,0,0))
if new_score>old_score:
old_score=new_score
score_music.play()
text=sss.render('SCORE:'+str(new_score),True,(0,0,0))
screen.blit(text,(0,0))
pygame.display.update()# 刷新画面
FPS.tick(50)
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