Commit 34f5e514 by BellCodeEditor

save project

parent ce16b2e4
Showing with 27 additions and 5 deletions
import pygame import pygame
from pygame import locals from pygame import locals
import random import random
import json
pygame.init() # 初始化 pygame.init() # 初始化
...@@ -55,6 +56,14 @@ old_score=0 ...@@ -55,6 +56,14 @@ old_score=0
speed=9 speed=9
block_list =pygame.sprite.Group() # 创建精灵组 block_list =pygame.sprite.Group() # 创建精灵组
with open('record.txt','r',encoding='utf-8') as file:
record1=file.read()
record=json.loads(record1)
one=record["第一名"]
two=record["第二名"]
three=record["第三名"]
while True: while True:
for event in pygame.event.get(): for event in pygame.event.get():
if event.type == locals.QUIT: if event.type == locals.QUIT:
...@@ -127,9 +136,22 @@ while True: ...@@ -127,9 +136,22 @@ while True:
score+=sprite.score score+=sprite.score
sprite.score=0 sprite.score=0
defen=pygame.font.Font('STKAITI.TTF',40) defen=pygame.font.Font('STKAITI.TTF',30)
text=defen.render('得分:'+str(score),True,(0,0,0)) text=defen.render('得分:'+str(score),True,(1,225,225))
screen.blit(text,(400,20)) screen.blit(text,(800,20))
reco1=pygame.font.Font('STKAITI.TTF',30)
record1=reco1.render('第一名:'+str(one),True,(0,0,0))
screen.blit(record1,(800,60))
reco2=pygame.font.Font('STKAITI.TTF',30)
record2=reco2.render('第二名:'+str(two),True,(0,0,0))
screen.blit(record2,(800,100))
reco3=pygame.font.Font('STKAITI.TTF',30)
record3=reco3.render('第一名:'+str(three),True,(0,0,0))
screen.blit(record3,(800,140))
score_audio=pygame.mixer.Sound('score.wav') score_audio=pygame.mixer.Sound('score.wav')
if score>old_score: if score>old_score:
......
{"第1名": 0, "第2名": 0, "第3名": 0} {"第一名": 0, "第二名": 0, "第三名": 0}
\ 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