Commit fa85591f by BellCodeEditor

save project

parent bf8ed74a
Showing with 9 additions and 4 deletions
...@@ -55,7 +55,7 @@ gamestate = True ...@@ -55,7 +55,7 @@ gamestate = True
# rect = obstacle.get_rect() # rect = obstacle.get_rect()
# rect.x = 1000 # rect.x = 1000
# rect.y = 500 - rect.height # rect.y = 500 - rect.height
oldscore=0
score=0 score=0
roadx=0 roadx=0
time=0 time=0
...@@ -69,6 +69,7 @@ while True: ...@@ -69,6 +69,7 @@ while True:
if jumpState == "runing": if jumpState == "runing":
if event.key == locals.K_SPACE: if event.key == locals.K_SPACE:
jumpState = "up" jumpState = "up"
speed=12+score//3
wukong = Player(hero[index]) wukong = Player(hero[index])
if jumpState == "runing": # 跑步状态下 if jumpState == "runing": # 跑步状态下
index += 1 index += 1
...@@ -103,7 +104,7 @@ while True: ...@@ -103,7 +104,7 @@ while True:
screen.blit(background, (bgx, 0)) screen.blit(background, (bgx, 0))
roadx -= 8 roadx -= speed
if roadx<=- 1000: if roadx<=- 1000:
roadx = 0 roadx = 0
screen.blit(road, (roadx, 500)) screen.blit(road, (roadx, 500))
...@@ -121,7 +122,7 @@ while True: ...@@ -121,7 +122,7 @@ while True:
for sprite in block_list: for sprite in block_list:
sprite.rect.x-=8 sprite.rect.x-=speed
screen.blit(sprite.image,(sprite.rect.x,sprite.rect.y)) screen.blit(sprite.image,(sprite.rect.x,sprite.rect.y))
if sprite.rect.x<= 0-sprite.rect.width: if sprite.rect.x<= 0-sprite.rect.width:
sprite.kill() sprite.kill()
...@@ -133,8 +134,11 @@ while True: ...@@ -133,8 +134,11 @@ while True:
if(sprite.rect.x+sprite.rect.width)<wukong.rect.x: if(sprite.rect.x+sprite.rect.width)<wukong.rect.x:
score+=sprite.score score+=sprite.score
sprite.score=0 sprite.score=0
if score>oldscore:
score_audio.play()
oldscore=score
scoresurf=basic_font.render('分数:'+str(score),True,(216,126,77)) scoresurf=basic_font.render('分数:'+str(score),True,(216,126,77))
screen.blit(scoresurf,(660,20)) screen.blit(scoresurf,(880,20))
# 刷新画面 # 刷新画面
pygame.display.update() pygame.display.update()
FPS.tick(60) FPS.tick(60)
\ No newline at end of file
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