Commit 32f12aca by BellCodeEditor

save project

parent f93f237a
Showing with 18 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() # 初始化
...@@ -53,8 +54,16 @@ time = 0 ...@@ -53,8 +54,16 @@ time = 0
gamestate = True gamestate = True
score = 0 score = 0
oldc = 0 oldc = 0
colornum = 0
block_list =pygame.sprite.Group() # 创建精灵组 block_list =pygame.sprite.Group() # 创建精灵组
with open('record.txt' , 'r' , encoding='utf-8') as f:
content = f.read()
record = json.loads(content)
one = record['第1名']
two = record['第2名']
tre = record['第3名']
while True: while True:
for event in pygame.event.get(): for event in pygame.event.get():
if event.type == locals.QUIT: if event.type == locals.QUIT:
...@@ -64,7 +73,7 @@ while True: ...@@ -64,7 +73,7 @@ while True:
if jumpState == "runing": if jumpState == "runing":
if event.key == locals.K_SPACE: if event.key == locals.K_SPACE:
jumpState = "up" jumpState = "up"
colornum += 1
speed = 8 + score // 3 speed = 8 + score // 3
# 悟空造型 # 悟空造型
wukong = Player(hero[index]) wukong = Player(hero[index])
...@@ -126,9 +135,15 @@ while True: ...@@ -126,9 +135,15 @@ while True:
if score > oldc: if score > oldc:
scaud.play() scaud.play()
oldc = score oldc = score
scoreSurf = basic_font.render("分数:"+str(score),True,(random.randint(0,255),random.randint(0,255),random.randint(0,255))) scoreSurf = basic_font.render("分数:"+str(score),True,(random.randint(0,255),random.randint(0,255),random.randint(0,255)))
screen.blit(scoreSurf,(850,20)) screen.blit(scoreSurf,(850,20))
scoreSurf = basic_font.render("第一名:"+str(one),True,(random.randint(0,255),random.randint(0,255),random.randint(0,255)))
screen.blit(scoreSurf,(830,60))
scoreSurf = basic_font.render("第二名:"+str(two),True,(random.randint(0,255),random.randint(0,255),random.randint(0,255)))
screen.blit(scoreSurf,(830,100))
scoreSurf = basic_font.render("第三名:"+str(tre),True,(random.randint(0,255),random.randint(0,255),random.randint(0,255)))
screen.blit(scoreSurf,(830,140))
# 刷新画面 # 刷新画面
pygame.display.update() pygame.display.update()
FPS.tick(60) FPS.tick(60)
\ 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