Commit 3ff07aad by BellCodeEditor

save project

parent 576951a8
Showing with 14 additions and 8 deletions
......@@ -40,6 +40,7 @@ hero = [pygame.image.load('hero1.png'),
pygame.image.load('hero3.png'),
pygame.image.load('hero4.png'),
pygame.image.load('hero5.png')]
sss=pygame.mixer.Sound('score.wav')
#basic_font = pygame.font.Font('STKAITI.TTF',32)
index = 0
y = 400
......@@ -48,6 +49,7 @@ jumpState = "runing"
t = 4
road_x = 0
bg_x = 0
oldscore=0
time = 0
speed=0
gamestate = True
......@@ -76,20 +78,20 @@ while True:
if t > 0:
y -= t
wukong.rect.y = y
t -= 0.01
t -= 0.02
else:
jumpState = "down"
if jumpState == "down": # 降落状态
if t <= 4:
y += t
wukong.rect.y = y
t += 0.01
t += 0.02
else:
jumpState = "runing"
t =4
# 将背景图画上去
bg_x -= 1
bg_x -= 1+score//10
if bg_x<=-1000:
bg_x = 0
screen.blit(background, (bg_x, 0)) # 远景
......@@ -102,10 +104,10 @@ while True:
screen.blit(wukong.image, (150, y)) # 悟空
time += 1
if time >= 60: # 创建障碍物精灵
if time >= 20: # 创建障碍物精灵
time = 0
num = random.randint(0,50)
if num > 20:
num = random.randint(0,10)
if num > 2:
obstacle = Block(bush,cacti,stone)
block_list.add(obstacle)
for sprite in block_list: # 遍历、展示障碍物精灵
......@@ -118,11 +120,14 @@ while True:
screen.blit(gameover, (400, 200))
gamestate = False
else:
score+=10
score+=10
if score>oldscore:
sss.play()
oldscore=score
#scoreSurf = basic_font.render("分数:"+str(score),True,(255,0,0))
#screen.blit(scoreSurf,(850,20))
# 刷新画面
pygame.display.update()
FPS.tick(60)
FPS.tick(600)
print(score)
\ 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