Commit 4b35b32a by BellCodeEditor

save project

parent 819259f2
Showing with 17 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() # 初始化
...@@ -42,7 +43,7 @@ hero = [pygame.image.load('hero1.png'), ...@@ -42,7 +43,7 @@ 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')]
basic_font=pygame.font.Font('STKAITI.TTF',18) basic_font=pygame.font.Font('STKAITI.TTF',18)
score_audio=pygame.mixer.Sound('score.wav') # score_audio=pygame.mixer.Sound('score.wav')
old_score=0 old_score=0
speed=8 speed=8
index = 0 index = 0
...@@ -54,10 +55,18 @@ bg_x = 0 ...@@ -54,10 +55,18 @@ bg_x = 0
time = 0 time = 0
gamestate = True gamestate = True
score=0 score=0
block_list =pygame.sprite.Group() # 创建精灵组 block_list =pygame.sprite.Group() # 创建精灵组
while True: 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名"]
speed=8+score//3 speed=8+score//3
while True:
for event in pygame.event.get(): for event in pygame.event.get():
if event.type == locals.QUIT: if event.type == locals.QUIT:
# 接收到退出事件后退出程序 # 接收到退出事件后退出程序
...@@ -126,6 +135,12 @@ while True: ...@@ -126,6 +135,12 @@ while True:
sprite.score=0 sprite.score=0
scoreSurf=basic_font.render("分数:"+str(score),True,(255,255,255)) scoreSurf=basic_font.render("分数:"+str(score),True,(255,255,255))
screen.blit(scoreSurf,(880,20)) screen.blit(scoreSurf,(880,20))
scoreSurf=basic_font.render("第1名:"+str(score),True,(255,255,255))
screen.blit(scoreSurf,(880,50))
scoreSurf=basic_font.render("第2名:"+str(score),True,(255,255,255))
screen.blit(scoreSurf,(880,80))
scoreSurf=basic_font.render("第2名:"+str(score),True,(255,255,255))
screen.blit(scoreSurf,(880,110))
# 刷新画面 # 刷新画面
if old_score<score: if old_score<score:
old_score=score old_score=score
......
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