Commit 52c68a72 by BellCodeEditor

save project

parent 8337023a
Showing with 16 additions and 3 deletions
import pygame
from pygame import locals
import random
import json
pygame.init() # 初始化
......@@ -27,6 +28,12 @@ class Player(pygame.sprite.Sprite): # 悟空
self.rect.y = 400
# 创建一个窗口
with open('record.txt','r',encoding='utf-8') as f:
cen = f.read()
record = json.loads(cen)
one = record["第1名"]
two = record["第2名"]
three= record["第3名"]
screen = pygame.display.set_mode((1000, 600))
FPS = pygame.time.Clock() # pygame时钟,控制游戏速度(帧数)
pygame.display.set_caption("悟空酷跑")
......@@ -67,8 +74,8 @@ while True:
if jumpState == "runing":
if event.key == locals.K_SPACE:
jumpState = "up"
if event.key == locals.K_D:
die = not die
# if event.key == locals.K_D:
# die = not die
# 悟空造型
wukong = Player(hero[index])
......@@ -134,8 +141,14 @@ while True:
scoresy.play()
old_score = score
scoreSurf = basic_font.render("分数:"+str(score),True,(255,0,0))
dieXX = basic_font.render("是否死亡"+str(die),True,(255,0,0))
screen.blit(scoreSurf,(850,20))
# dieXX = basic_font.render("是否死亡"+str(die),True,(255,0,0))
scoreSurf = basic_font.render("第一名:"+str(one),True,(255,0,0))
screen.blit(scoreSurf,(850,40))
scoreSurf = basic_font.render("第二名:"+str(one),True,(255,0,0))
screen.blit(scoreSurf,(850,60))
scoreSurf = basic_font.render("第三名:"+str(one),True,(255,0,0))
screen.blit(scoreSurf,(850,80))
# 刷新画面
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