Commit 336a7689 by BellCodeEditor

save project

parent 09b4910c
Showing with 14 additions and 0 deletions
import pygame import pygame
from pygame import locals from pygame import locals
import random import random
import json
pygame.init() # 初始化 pygame.init() # 初始化
# 创建一个窗口 # 创建一个窗口
...@@ -37,6 +38,12 @@ class Player(pygame.sprite.Sprite): ...@@ -37,6 +38,12 @@ class Player(pygame.sprite.Sprite):
self.rect = self.image.get_rect() self.rect = self.image.get_rect()
self.rect.x = 150 self.rect.x = 150
self.rect.y = 400 self.rect.y = 400
with open('record.txt','r',encoding='utf-8') as f:
mingci = f.read()
record=json.loads(mingci)
one = record["第1名"]
two = record["第2名"]
three = record["第3名"]
index = 0 index = 0
y = 400 y = 400
...@@ -125,6 +132,12 @@ while True: ...@@ -125,6 +132,12 @@ while True:
scoreziti = ziti.render("分數:"+str(score),True,(255,255,255)) scoreziti = ziti.render("分數:"+str(score),True,(255,255,255))
screen.blit(scoreziti,(880,20)) screen.blit(scoreziti,(880,20))
scoreziti = ziti.render("第一名:"+str(one),True,(255,255,255))
screen.blit(scoreziti,(880,50))
scoreziti = ziti.render("第二名:"+str(two),True,(255,255,255))
screen.blit(scoreziti,(880,80))
scoreziti = ziti.render("第三名:"+str(three),True,(255,255,255))
screen.blit(scoreziti,(880,110))
# 刷新画面 # 刷新画面
pygame.display.update() pygame.display.update()
FPS.tick(60) FPS.tick(60)
\ 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