Commit 2b8bcb8b by BellCodeEditor

save project

parent 339bbc84
Showing with 8 additions and 4 deletions
...@@ -35,6 +35,7 @@ hero = [pygame.image.load('hero1.png'), ...@@ -35,6 +35,7 @@ hero = [pygame.image.load('hero1.png'),
pygame.image.load('hero4.png'), pygame.image.load('hero4.png'),
pygame.image.load('hero5.png')] pygame.image.load('hero5.png')]
basic_font = pygame.font.Font('STKAITI.TTF',32) basic_font = pygame.font.Font('STKAITI.TTF',32)
score_audio=pygame.mixer.Sound('score.wav')
lu_x=0 lu_x=0
shan_x=0 shan_x=0
index = 0 index = 0
...@@ -60,7 +61,7 @@ while True: ...@@ -60,7 +61,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=8+score//3
wukong = Player(hero[index]) # 悟空造型 wukong = Player(hero[index]) # 悟空造型
if jumpState == "runing": # 跑步状态下 if jumpState == "runing": # 跑步状态下
index += 1 index += 1
...@@ -88,7 +89,7 @@ while True: ...@@ -88,7 +89,7 @@ while True:
if bg_x <-1000: if bg_x <-1000:
bg_x=0 bg_x=0
screen.blit(background, (bg_x, 0)) # 远处背景 screen.blit(background, (bg_x, 0)) # 远处背景
road_x -=8 road_x -=speed
if road_x <-1000: if road_x <-1000:
road_x=0 road_x=0
screen.blit(road, (road_x, 500)) # 路 screen.blit(road, (road_x, 500)) # 路
...@@ -109,7 +110,7 @@ while True: ...@@ -109,7 +110,7 @@ while True:
Block_list.add(obstacle) Block_list.add(obstacle)
time=0 time=0
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 prop.rect.x<=0-prop.rect.width: if prop.rect.x<=0-prop.rect.width:
prop.kill() prop.kill()
...@@ -123,7 +124,9 @@ while True: ...@@ -123,7 +124,9 @@ while True:
prop.score=0 prop.score=0
f = basic_font.render('分数:'+str(score),True,(255,0,0)) f = basic_font.render('分数:'+str(score),True,(255,0,0))
screen.blit(f,(850,20)) screen.blit(f,(850,20))
if score > old_score:
score_audio.play()
old_score=score
# 刷新画面 # 刷新画面
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