Skip to content
  • P
    Projects
  • G
    Groups
  • S
    Snippets
  • Help

Administrator / pygame_lesson9_diy4

  • This project
    • Loading...
  • Sign in
Go to a project
  • Project
  • Repository
  • Issues 0
  • Merge Requests 0
  • Pipelines
  • Wiki
  • Snippets
  • Members
  • Activity
  • Graph
  • Charts
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Files
  • Commits
  • Branches
  • Tags
  • Contributors
  • Graph
  • Compare
  • Charts
Commit 7052df08 authored 4 years ago by BellCodeEditor's avatar BellCodeEditor
Browse files
Options
  • Browse Files
  • Download
  • Email Patches
  • Plain Diff

save project

parent 706ff550 c157108l1437p256a14523/wx175105
Show whitespace changes
Inline Side-by-side
Showing with 8 additions and 3 deletions
  • my_game.py
  • record.txt
my_game.py
View file @ 7052df08
......@@ -42,7 +42,7 @@ hero = [pygame.image.load('hero1.png'),
pygame.image.load('hero3.png'),
pygame.image.load('hero4.png'),
pygame.image.load('hero5.png')]
basic_font=pygame.font.Font('STKAITI.TTF',18)
basic_font=pygame.font.Font('STKAITI.TTF',30)
score_audio=pygame.mixer.Sound('score.wav')
index = 0
......@@ -56,6 +56,7 @@ gamestate = True
score=0
speed=8
old_score=0
again=0
block_list =pygame.sprite.Group() # 创建精灵组
......@@ -133,6 +134,9 @@ while True:
gameover = pygame.image.load('gameover.png') # 游戏结束
screen.blit(gameover,(400, 200))
gamestate = False
if gamestate==False:
m=basic_font.render("游戏结束,按任意键重新开始",True,(60,90,60))
screen.blit(m,(350,300))
if score>one:
record["第1名"]=score
record["第2名"]=one
......@@ -146,6 +150,7 @@ while True:
with open('record.txt','w',encoding='utf-8') as f:
f.write(record)
else:
if sprite.rect.x+sprite.rect.width<wukong.rect.x:
score+=sprite.score
......
This diff is collapsed. Click to expand it.
record.txt
View file @ 7052df08
{"第1名": 8, "第2名": 4, "第3名": 1}
\ No newline at end of file
{"第1名": 13, "第2名": 12, "第3名": 8}
\ No newline at end of file
This diff is collapsed. Click to expand it.
  • Write
  • Preview
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