Commit d55791a2 by BellCodeEditor

save project

parent 97450661
Showing with 15 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):
...@@ -39,6 +40,12 @@ hero = [pygame.image.load('hero1.png'), ...@@ -39,6 +40,12 @@ hero = [pygame.image.load('hero1.png'),
pygame.image.load('hero4.png'), pygame.image.load('hero4.png'),
pygame.image.load('hero5.png')] pygame.image.load('hero5.png')]
get_score=pygame.mixer.Sound('score.wav') get_score=pygame.mixer.Sound('score.wav')
with open('score.txt','r',encoding='utf-8') as file:
r0=file.read()
record=json.loads(r0)
r1=record["第一名"]
r2=record["第二名"]
r3=record["第三名"]
index = 0 index = 0
pygame.display.set_caption('悟空酷跑') pygame.display.set_caption('悟空酷跑')
a=0 a=0
...@@ -94,6 +101,12 @@ while True: ...@@ -94,6 +101,12 @@ while True:
#z_x-=8 #z_x-=8
text=font.render('分数:'+str(score),True,(255,255,255)) text=font.render('分数:'+str(score),True,(255,255,255))
screen.blit(text,(880,20)) screen.blit(text,(880,20))
r11=font.render('第一名:'+str(r1),True,(255,255,255))
r22=font.render('第二名:'+str(r2),True,(255,255,255))
r33=font.render('第三名: '+str(r3),True,(255,255,255))
screen.blit(r11,(880,40))
screen.blit(r22,(880,60))
screen.blit(r33,(880,80))
road_x-=speed road_x-=speed
bg_x-=1 bg_x-=1
#if zaw.rect.x<= 0-zaw.rect.width: #if zaw.rect.x<= 0-zaw.rect.width:
......
{"第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