Commit 64bfc0c5 by BellCodeEditor

save project

parent 9f65c214
Showing with 28 additions and 1 deletions
import pygame
from pygame import locals
import random
import json
pygame.init
class Block(pygame.sprite.Sprite):
def __init__(self,image1,image2,image3):
......@@ -45,6 +47,13 @@ screen = 0
old_screen = screen
block_list = pygame.sprite.Group()
with open('score.txt', 'r', encoding='utf-8') as f:
content = f.read()
record = json.loads(content)
one = content["第一名"]
two = content["第二名"]
thr = content["第三名"]
while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
......@@ -90,6 +99,17 @@ while True:
gameover = pygame.image.load('gameover.png')
screen.blit(gameover, (400, 200))
gametate = False
if score>three:
if score>one:
record["第一名"] = score
record["第二名"] = one
record["第三名"] = two
elif score > two:
record["第二名"] = score
record["第三名"] = two
else:
record["第三名"] = score
record = json.dumps(record, ensure_ascii=False)
else:
if(sprite.rect.x + sprite.rect.width) < wukong.rect.x:
score += sprite.score
......@@ -103,7 +123,14 @@ while True:
aa.rect.x -= 8
scoreSurf = basic_font.render("分数:"+str(score), True,(255, 255, 255))
screen.blit(scoreSurf,(880,20))
scoreSurf = basic_font.render("第一名:"+str(one), True,(255, 255, 255))
screen.blit(scoreSurf,(880,50))
scoreSurf = basic_font.render("第二名:"+str(two), True,(255, 255, 255))
screen.blit(scoreSurf,(880,80))
scoreSurf = basic_font.render("第三名:"+str(thr), True,(255, 255, 255))
screen.blit(scoreSurf,(880,110))
screen.blit(aa.image, (aa.rect.x, aa.rect.y))
# 刷新画面
pygame.display.update()
......
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