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

Administrator / pygame_lesson9_diy1

  • 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 9769367d authored 4 years ago by BellCodeEditor's avatar BellCodeEditor
Browse files
Options
  • Browse Files
  • Download
  • Email Patches
  • Plain Diff

save project

parent 7074ca58
Hide whitespace changes
Inline Side-by-side
Showing with 8 additions and 3 deletions
  • my_game.py
my_game.py
View file @ 9769367d
......@@ -30,6 +30,7 @@ screen = pygame.display.set_mode((1000, 600))
FPS = pygame.time.Clock() # pygame时钟,控制游戏速度(帧数)
pygame.display.set_caption("悟空酷跑")
# 载入图片
score_audio=pygame.mixer.Sound('score.wav')
background = pygame.image.load('bg.png') # 背景
road = pygame.image.load('road.png') # 路
stone = pygame.image.load('stone.png') # 石头
......@@ -44,13 +45,14 @@ basic_font=pygame.font.Font('STKAITI.TTF',17)
index = 0
y = 400
jumpState = "runing"
t = 30
t = 40
road_x = 0
bg_x = 0
time = 0
speed=8
gamestate = True
score=0
old_score=score
block_list =pygame.sprite.Group() # 创建精灵组
while True:
......@@ -79,13 +81,13 @@ while True:
else:
jumpState = "down"
if jumpState == "down": # 降落状态
if t <= 30:
if t <= 40:
y += t
wukong.rect.y = y
t += 2
else:
jumpState = "runing"
t =30
t =40
# 将背景图画上去
bg_x -= 1
......@@ -120,6 +122,9 @@ while True:
if(sprite.rect.x+sprite.rect.width)<wukong.rect.x:
score+=sprite.score
sprite.score=0
if score>old_score:
score_audio.play()
old_score=score
#fenshu
scoreSulf=basic_font.render("分数:"+str(score),True,(123,111,111))
screen.blit(scoreSulf,(800,20))
......
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