Commit 46909558 by BellCodeEditor

auto save

parent ee799b49
Showing with 15 additions and 0 deletions
import pygame
from pygame import locals
import random
import json
pygame.init() # 初始化
......@@ -55,6 +56,14 @@ score = 0
old_score = 0
block_list =pygame.sprite.Group() # 创建精灵组
speed = 8
with open("record.txt","r",encoding="utf-8") as file:
date = file.read()
dic_date = json.loads(date)
first = "第一名:"+str(dic_date['第1名'])
second = "第二名:"+str(dic_date['第2名'])
third = "第三名:"+str(dic_date['第3名'])
while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
......@@ -123,6 +132,12 @@ while True:
gamestate = False
scoreSurf = basic_font.render("分数:"+str(score),True,(255,0,0))
screen.blit(scoreSurf,(850,20))
scoreSurf = basic_font.render(first,True,(255,0,0))
screen.blit(scoreSurf,(850,50))
scoreSurf = basic_font.render(second,True,(0,255,0))
screen.blit(scoreSurf,(850,80))
scoreSurf = basic_font.render(third,True,(0,0,255))
screen.blit(scoreSurf,(850,110))
if score > old_score:
score_audio.play()
old_score = score
......
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