Commit 28979cee by BellCodeEditor

save project

parent 02309e6f
Showing with 10 additions and 5 deletions
...@@ -40,7 +40,9 @@ hero = [pygame.image.load('hero1.png'), ...@@ -40,7 +40,9 @@ hero = [pygame.image.load('hero1.png'),
pygame.image.load('hero3.png'), pygame.image.load('hero3.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',18) score_audio = pygame.mixer.Sound('score.wav')
basic_font = pygame.font.Font('STKAITI.TTF',18)#字体
old_score = 0
index = 0 index = 0
y = 400 y = 400
jumpState = "runing" jumpState = "runing"
...@@ -51,7 +53,7 @@ time = 0 ...@@ -51,7 +53,7 @@ time = 0
gamestate = True gamestate = True
score = 0 score = 0
block_list =pygame.sprite.Group() # 创建精灵组 block_list =pygame.sprite.Group() # 创建精灵组
speed = 8
while True: while True:
for event in pygame.event.get(): for event in pygame.event.get():
if event.type == locals.QUIT: if event.type == locals.QUIT:
...@@ -61,7 +63,7 @@ while True: ...@@ -61,7 +63,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": # 跑步状态下
...@@ -92,7 +94,7 @@ while True: ...@@ -92,7 +94,7 @@ while True:
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)) # 道路
...@@ -119,7 +121,10 @@ while True: ...@@ -119,7 +121,10 @@ 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
print(score) if score > old_score:
score_audio.play()
old_score = score
#print(score)
scoreSurf = basic_font.render("分数:"+str(score),True,(225,225,225)) scoreSurf = basic_font.render("分数:"+str(score),True,(225,225,225))
screen.blit(scoreSurf,(880,20)) screen.blit(scoreSurf,(880,20))
# 刷新画面 # 刷新画面
......
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