Commit a0f744e9 by BellCodeEditor

save project

parent 3bb2e58c
Showing with 12 additions and 2 deletions
import pygame import pygame
from pygame import locals from pygame import locals
import random import random
import json
pygame.init() # 初始化 pygame.init() # 初始化
class Block(pygame.sprite.Sprite): # 障碍物精灵类 class Block(pygame.sprite.Sprite): # 障碍物精灵类
...@@ -48,8 +48,15 @@ road_x = 0 ...@@ -48,8 +48,15 @@ road_x = 0
bg_x = 0 bg_x = 0
time = 0 time = 0
gamestate = True gamestate = True
score = 0
block_list =pygame.sprite.Group() # 创建精灵组 block_list =pygame.sprite.Group()
with open('record.txt','r', encoding = 'utf-8') as f: # 创建精灵组
content = f.read()
recrod = json.loads(content)
one= recrod["第1名"]
two= recrod["第2名"]
wer= recrod["第3名"]
while True: while True:
for event in pygame.event.get(): for event in pygame.event.get():
...@@ -114,6 +121,9 @@ while True: ...@@ -114,6 +121,9 @@ while True:
gameover = pygame.image.load('gameover.png') # 游戏结束 gameover = pygame.image.load('gameover.png') # 游戏结束
screen.blit(gameover, (400, 200)) screen.blit(gameover, (400, 200))
gamestate = False gamestate = False
if score > wer:
if score.one:
record[]
# 刷新画面 # 刷新画面
pygame.display.update() 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