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

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

save project

parent ed5ec3f1 c200865l1354p256a13982/wx618338
Hide whitespace changes
Inline Side-by-side
Showing with 5 additions and 3 deletions
  • snake.py
snake.py
View file @ a93b45e3
......@@ -8,6 +8,7 @@ pygame.init()
screen = pygame.display.set_mode((660, 480))
FPSCLOCK = pygame.time.Clock() # pygame时钟,控制游戏速度(帧数)
my_font=pygame.font.Font
# 背景
background = pygame.image.load('bg.png')
right = pygame.image.load('right.png') # 头 朝右
......@@ -45,13 +46,14 @@ while True:
snake_head = down
# 设置贪吃蛇的头部坐标
if setheading == "right":
if x<0 or x>630 or y<0 or y>450:
if setheading == "light"
x += 30
elif setheading == "left":
x -= 30
elif setheading == "up":
y -= 30
else:
else:setheading =="donw"
y += 30
if x==apple_x and y==apple_y:
apple_x = 30*random.randint(1,22)
......@@ -65,7 +67,7 @@ while True:
# 将贪吃蛇的身体画上去
info = "score:"+str(score)
text = my_font.render(info,true,(0,0,0))
screen.blit(text,(540,10))
screen.blit(text,(530,10))
for i in range(len(position)-1):
screen.blit(body, position[i])
......
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