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

Administrator / pygame_lesson7_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 effea78b authored 3 years ago by BellCodeEditor's avatar BellCodeEditor
Browse files
Options
  • Browse Files
  • Download
  • Email Patches
  • Plain Diff

save project

parent 23e444c6 c198860l1405p256a14327/wx876872
Hide whitespace changes
Inline Side-by-side
Showing with 18 additions and 1 deletions
  • my_game.py
my_game.py
View file @ effea78b
......@@ -20,6 +20,8 @@ hero5= pygame.image.load('hero5.png')
hero=[hero1,hero2,hero3,hero4,hero5]
index = 0
a=0
y=400
runstate="running"
pygame.display.set_caption("悟空酷跑")
while True:
b=random.randint(60,100)
......@@ -27,6 +29,20 @@ while True:
if event.type == locals.QUIT:
# 接收到退出事件后退出程序
exit()
if event.type==locals.KEYDOWN:
if event.key==locals.K_SPACE:
runstate="up"
if runstate=="up":
if y>150:
y-=5
else:
runstate="down"
if runstate=="down":
if y<400:
y+=5
else:
runstate=="running"
a+=1
if a==len(hero)-1:
a=0
......@@ -34,7 +50,7 @@ while True:
# 将背景图画上去
screen.blit(background, (0, 0))
screen.blit(road, (0, 500))
screen.blit(mode, (150, 400))
screen.blit(mode, (150, y))
# 刷新画面
pygame.display.update()
FPS.tick(b)
\ 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