Commit 07d5e9c2 by BellCodeEditor

save project

parent 559b45b0
Showing with 14 additions and 1 deletions
import pygame import pygame
from pygame import locals from pygame import locals
import random import random
import json
pygame.init() # 初始化 pygame.init() # 初始化
class Block(pygame.sprite.Sprite): # 障碍物精灵类 class Block(pygame.sprite.Sprite): # 障碍物精灵类
...@@ -43,6 +43,12 @@ hero = [pygame.image.load('hero1.png'), ...@@ -43,6 +43,12 @@ hero = [pygame.image.load('hero1.png'),
pygame.image.load('hero5.png')] pygame.image.load('hero5.png')]
score_music=pygame.mixer.Sound('score.wav') score_music=pygame.mixer.Sound('score.wav')
basic_font = pygame.font.Font('MSYH.TTF',18) basic_font = pygame.font.Font('MSYH.TTF',18)
with open('record.txt','r',encoding='utf-8')as f:
cen=f.read()
record=json.loads(cen)
one=record["第1名"]
two=record["第2名"]
three=record["第3名"]
index = 0 index = 0
y = 400 y = 400
jumpState = "runing" jumpState = "runing"
...@@ -125,6 +131,12 @@ while True: ...@@ -125,6 +131,12 @@ while True:
sprite.score=0 sprite.score=0
scoreSurf = basic_font.render("分数:"+str(score),True,(255,0,0)) scoreSurf = basic_font.render("分数:"+str(score),True,(255,0,0))
screen.blit(scoreSurf,(850,20)) screen.blit(scoreSurf,(850,20))
scoreSurf = basic_font.render("第1名:"+str(score),True,(255,0,0))
screen.blit(scoreSurf,(850,50))
scoreSurf = basic_font.render("第2名:"+str(score),True,(255,0,0))
screen.blit(scoreSurf,(850,80))
scoreSurf = basic_font.render("第3名:"+str(score),True,(255,0,0))
screen.blit(scoreSurf,(850,110))
# 刷新画面 # 刷新画面
pygame.display.update() pygame.display.update()
FPS.tick(30) FPS.tick(30)
\ 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