Commit e8d218f5 by BellCodeEditor

save project

parent f4d312ec
Showing with 20 additions and 4 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,15 @@ hero = [pygame.image.load('hero1.png'), ...@@ -43,6 +43,15 @@ hero = [pygame.image.load('hero1.png'),
pygame.image.load('hero5.png')] pygame.image.load('hero5.png')]
font = pygame.font.Font("STKAITI.TTF",25) font = pygame.font.Font("STKAITI.TTF",25)
music = pygame.mixer.Sound("score.wav") music = pygame.mixer.Sound("score.wav")
with open("record.txt",'r',encoding = "utf-8") as f :
json_txt = f.read()
python_txt = json.loads(json_txt)
first = "第一名:" + str(python_txt["第1名"])
scond = "第二名:" + str(python_txt["第2名"])
third = "第三名:" + str(python_txt["第3名"])
print(first)
print(scond)
print(third)
index = 0 index = 0
y = 400 y = 400
jumpState = "runing" jumpState = "runing"
...@@ -123,7 +132,13 @@ while True: ...@@ -123,7 +132,13 @@ while True:
# gamestate = False # gamestate = False
info = "Score:" + str(score) info = "Score:" + str(score)
my_font = font.render(info,True,(0,0,0)) my_font = font.render(info,True,(0,0,0))
screen.blit(my_font,(880,20)) f_txt = font.render(first,True,(0,0,0))
s_txt = font.render(scond,True,(0,0,0))
t_txt = font.render(third,True,(0,0,0))
screen.blit(my_font,(870,20))
screen.blit(f_txt,(870,50))
screen.blit(s_txt,(870,80))
screen.blit(t_txt,(870,110))
# 刷新画面 # 刷新画面
pygame.display.update() pygame.display.update()
FPS.tick(60) FPS.tick(60)
\ No newline at end of file
{"第1名": 0, "第2名": 0, "第3名": 0} {"第1名": 11, "第2名": 22, "第3名": 33}
\ No newline at end of file \ 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