Commit 619d026c by BellCodeEditor

auto save

parent 41792fd2
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() # 初始化
...@@ -15,6 +16,7 @@ class Block(pygame.sprite.Sprite): # 障碍物精灵类 ...@@ -15,6 +16,7 @@ class Block(pygame.sprite.Sprite): # 障碍物精灵类
self.rect.x = 1000 self.rect.x = 1000
self.rect.y = 500 - self.rect.height self.rect.y = 500 - self.rect.height
class Player(pygame.sprite.Sprite): # 悟空 class Player(pygame.sprite.Sprite): # 悟空
def __init__(self, image): def __init__(self, image):
super().__init__() super().__init__()
...@@ -52,7 +54,19 @@ time = 0 ...@@ -52,7 +54,19 @@ time = 0
score=0 score=0
gamestate = True gamestate = True
block_list =pygame.sprite.Group() # 创建精灵组 block_list =pygame.sprite.Group()
# 创建精灵组
with open('record.txt','r',encoding='utf-8')as f:
content=f.read()
content=json.loads(content)
one=record("第一名")
two=record("第二名")
three=record("第三名")
while True: while True:
for event in pygame.event.get(): for event in pygame.event.get():
...@@ -121,7 +135,6 @@ while True: ...@@ -121,7 +135,6 @@ while True:
if sprite.rect.width+sprite.rect.x<wukong.rect.x: if sprite.rect.width+sprite.rect.x<wukong.rect.x:
score+=sprite.score score+=sprite.score
sprite.score=0 sprite.score=0
if score>sprite.score: hgfwjkjwadkjaidwdjw
music_score.play() music_score.play()
scoreSurf = basic_font.render("分数:"+str(score),True,(255,0,0)) scoreSurf = basic_font.render("分数:"+str(score),True,(255,0,0))
screen.blit(scoreSurf,(850,20)) screen.blit(scoreSurf,(850,20))
......
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