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

Administrator / pygame_lesson3_diy3

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

save project

parent 5f89ca1e
Hide whitespace changes
Inline Side-by-side
Showing with 7 additions and 0 deletions
  • snake.py
snake.py
View file @ ab0805d7
...@@ -9,6 +9,7 @@ screen = pygame.display.set_mode((660, 480)) ...@@ -9,6 +9,7 @@ screen = pygame.display.set_mode((660, 480))
FPSCLOCK = pygame.time.Clock() # pygame时钟,控制游戏速度(帧数) FPSCLOCK = pygame.time.Clock() # pygame时钟,控制游戏速度(帧数)
# 背景 # 背景
background = pygame.image.load('bg.png') background = pygame.image.load('bg.png')
right = pygame.image.load('right.png') # 头 朝右 right = pygame.image.load('right.png') # 头 朝右
food = pygame.image.load('apple.png') # 食物 苹果 food = pygame.image.load('apple.png') # 食物 苹果
...@@ -20,12 +21,16 @@ down = pygame.image.load('down.png') # 头 朝下 ...@@ -20,12 +21,16 @@ down = pygame.image.load('down.png') # 头 朝下
x, y = 240, 120 x, y = 240, 120
position = [(180, 90), (180, 120), (210, 120), (x, y)] position = [(180, 90), (180, 120), (210, 120), (x, y)]
random
setheading = "right" setheading = "right"
snake_head = right snake_head = right
apple_x=630 apple_x=630
apple_y=420 apple_y=420
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()
...@@ -53,6 +58,8 @@ while True: ...@@ -53,6 +58,8 @@ while True:
else: else:
y += 30 y += 30
position.append((x, y)) position.append((x, y))
# a=pygame.font.Font('neuropol.tty',18)
# b=pygame.font.Font('Score:10',Ture,(0,0,0))
if x == apple_x and y == apple_y: if x == apple_x and y == apple_y:
nun1=random.randint(1,22) nun1=random.randint(1,22)
......
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