Commit 2f2b9350 by BellCodeEditor

save project

parent f3f27a7f
Showing with 20 additions and 4 deletions
import pygame import pygame
from pygame import locals from pygame import locals
import random import random
import json
pygame.init() # 初始化 pygame.init() # 初始化
...@@ -43,6 +44,7 @@ hero = [pygame.image.load('hero1.png'), ...@@ -43,6 +44,7 @@ hero = [pygame.image.load('hero1.png'),
pygame.image.load('hero5.png')] pygame.image.load('hero5.png')]
basic_font = pygame.font.Font('STKAITI.TTF',32) basic_font = pygame.font.Font('STKAITI.TTF',32)
score_audio = pygame.mixer.Sound('score.wav') score_audio = pygame.mixer.Sound('score.wav')
index = 0 index = 0
y = 400 y = 400
jumpState = "runing" jumpState = "runing"
...@@ -52,10 +54,15 @@ bg_x = 0 ...@@ -52,10 +54,15 @@ bg_x = 0
time = 0 time = 0
gamestate = True gamestate = True
score = 0 score = 0
speed = 8 old_score = score
old_score = 0
block_list =pygame.sprite.Group() # 创建精灵组 block_list =pygame.sprite.Group()
with open('score.txt','r',encoding='utf-8')as f:
content = f.read()
recoad = json.loads(content)
one =content["第1名"]
two =content["第2名"]
three =content["第3名"] # 创建精灵组
while True: while True:
for event in pygame.event.get(): for event in pygame.event.get():
...@@ -131,8 +138,17 @@ while True: ...@@ -131,8 +138,17 @@ while True:
score_audio.play() score_audio.play()
old_score = score old_score = score
scoreSurf = basic_font.render("分数:"+str(score),True,(255,0,0))
scoreSurf = basic_font.render("分数:"+str(score),True,(255,255,255))
screen.blit(scoreSurf,(850,20)) screen.blit(scoreSurf,(850,20))
scoreSurf = basic_font.render("第1名:"+str(one),True,(255,255,255))
screen.blit(scoreSurf,(850,50))
scoreSurf = basic_font.render("第2名:"+str(two)),True,(255,255,255))
screen.blit(scoreSurf,(850,80))
scoreSurf = basic_font.render("第3名:"+str(three),True,(255,255,255))
screen.blit(scoreSurf,(850,110))
# 刷新画面 # 刷新画面
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