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

save project

parent 5e1ac9b5
Hide whitespace changes
Inline Side-by-side
Showing with 9 additions and 5 deletions
  • my_game.py
my_game.py
View file @ d7de1414
...@@ -19,28 +19,32 @@ hero = [pygame.image.load('hero1.png'), ...@@ -19,28 +19,32 @@ hero = [pygame.image.load('hero1.png'),
index = 0 index = 0
zhuangtai = "running" zhuangtai = "running"
y = 400 y = 400
nu = 30
while True: while True:
for event in pygame.event.get(): for event in pygame.event.get():
if event.type == locals.QUIT: if event.type == locals.QUIT:
# 接收到退出事件后退出程序 # 接收到退出事件后退出程序
exit() exit()
if event.type ==locals.KEYDOWN: if event.type ==locals.KEYDOWN:
if event.key == locals.K_SPACE: if event.key == locals.K_SPACE:
zhuangtai = "up" zhuangtai = "up"
if zhuangtai == "up": if zhuangtai == "up":
if y > 150: if nu > 0:
y-=5 y -= nu
nu -=2
else: else:
zhuangtai = "down" zhuangtai = "down"
if zhuangtai == "down": if zhuangtai == "down":
if y < 400: if nu <= 30:
y += 5 y += nu
nu += 2
else: else:
zhuangtai = "running" zhuangtai = "running"
nu = 30
wukong = hero[index] wukong = hero[index]
index += 1 index += 1
......
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