Commit 96439e85 by BellCodeEditor

save project

parent 8462f98c
Showing with 20 additions and 1 deletions
import pygame import pygame
from pygame import locals from pygame import locals
import random import random
import json
pygame.init() # 初始化 pygame.init() # 初始化
# 创建一个窗口 # 创建一个窗口
...@@ -46,9 +47,20 @@ time = 0 ...@@ -46,9 +47,20 @@ time = 0
Game = True Game = True
score = 0 score = 0
speed = 8 speed = 8
music_1 = pygame.mixer.Sound("score.wav")
old_score = 0
with open("score.txt","r",encoding = "utf-8") as f:
content = f.read()
record = json.loads(content)
one = record["第1名"]
two = record["第2名"]
three = record["第3名"]
while True: while True:
speed = 8 + score // 3 speed = 8 + score // 3
if score > old_score:
music_1.play()
old_score = score
for event in pygame.event.get(): for event in pygame.event.get():
if event.type == locals.QUIT: if event.type == locals.QUIT:
# 接收到退出事件后退出程序 # 接收到退出事件后退出程序
...@@ -112,6 +124,12 @@ while True: ...@@ -112,6 +124,12 @@ while True:
# 刷新画面 # 刷新画面
info = "分数:" + str(score) info = "分数:" + str(score)
text = font.render(info,True,(255,255,255)) text = font.render(info,True,(255,255,255))
screen.blit(text,(900,20)) screen.blit(text,(880,20))
one_1 = font.render("第一名:" + str(one),True,(255,255,255))
screen.blit(one_1,(880,40))
two_1 = font.render("第二名:" + str(two),True,(255,255,255))
screen.blit(two_1,(880,60))
three_1 = font.render("第三名:" + str(one),True,(255,255,255))
screen.blit(three_1,(880,80))
pygame.display.update() pygame.display.update()
FPS.tick(60) FPS.tick(60)
\ No newline at end of file
File added
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