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

save project

parent 764c6008
Hide whitespace changes
Inline Side-by-side
Showing with 7 additions and 1 deletions
  • snake.py
snake.py
View file @ 0c2dcf7f
...@@ -20,12 +20,17 @@ down = pygame.image.load('down.png') # 头 朝下 ...@@ -20,12 +20,17 @@ down = pygame.image.load('down.png') # 头 朝下
ax=360 ax=360
ay=300 ay=300
x, y = 240, 120 x, y = 240, 120
s=0
m=pygame.font.Font("neuropol.ttf",100)
i="傻逼"+str(s)
t=m.render(i,False,[100,255,100])
position = [(180, 90), (180, 120), (210, 120), (x, y)] position = [(180, 90), (180, 120), (210, 120), (x, y)]
setheading = "right" setheading = "right"
snake_head = right snake_head = right
while True: while True:
s+=1
for event in pygame.event.get(): for event in pygame.event.get():
if event.type == locals.QUIT: if event.type == locals.QUIT:
# 接收到退出事件后退出程序 # 接收到退出事件后退出程序
...@@ -57,6 +62,7 @@ while True: ...@@ -57,6 +62,7 @@ while True:
if ax==x and ay==y: if ax==x and ay==y:
ax=30*random.randint(0,21) ax=30*random.randint(0,21)
ay=30*random.randint(0,15) ay=30*random.randint(0,15)
s-=10
else: else:
position.pop(0) position.pop(0)
# 将背景图画上去 # 将背景图画上去
...@@ -67,7 +73,7 @@ while True: ...@@ -67,7 +73,7 @@ while True:
# 将贪吃蛇的身体画上去 # 将贪吃蛇的身体画上去
for i in range(len(position)-1): for i in range(len(position)-1):
screen.blit(body, position[i]) screen.blit(body, position[i])
screen.blit(text(0,0))
# 将果实画上去 # 将果实画上去
# 刷新画面 # 刷新画面
......
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