Commit fe1d2818 by BellCodeEditor

auto save

parent a55476e6
Showing with 16 additions and 2 deletions
import pygame
from pygame import locals
import random
import json
pygame.init() # 初始化
......@@ -55,6 +56,13 @@ gamestate = True
score=0
old_score=0
block_list =pygame.sprite.Group() # 创建精灵组
with open("record.txt","r",encoding="utf-8") as f:
content=f.read()
record=json.loads(content)
one=record["第1名"]
two=record["第2名"]
three=record["第3名"]
speed=8
while True:
for event in pygame.event.get():
......@@ -128,6 +136,12 @@ while True:
old_score=score
scoreSurf = basic_font.render("Score:"+str(score),True,(255,0,0))
screen.blit(scoreSurf,(850,20))
scoreSurf = basic_font.render("NO.1:"+str(one),True,(255,0,0))
screen.blit(scoreSurf,(850,50))
scoreSurf = basic_font.render("NO.2:"+str(two),True,(255,0,0))
screen.blit(scoreSurf,(850,80))
scoreSurf = basic_font.render("NO.3:"+str(three),True,(255,0,0))
screen.blit(scoreSurf,(850,110))
# 刷新画面
pygame.display.update()
......
{"第1名": 0, "第2名": 0, "第3名": 0}
\ No newline at end of file
{"第1名": 5, "第2名": 3, "第3名": 2}
\ 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