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

Administrator / pygame_lesson3_diy2

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

save project

parent 9f31455b c136317l1354p256a13983/wx701349
Hide whitespace changes
Inline Side-by-side
Showing with 7 additions and 1 deletions
  • snake.py
snake.py
View file @ ca147088
...@@ -10,8 +10,10 @@ screen = pygame.display.set_mode((660, 480)) ...@@ -10,8 +10,10 @@ screen = pygame.display.set_mode((660, 480))
x,y=240, 120 x,y=240, 120
food_x=360 food_x=360
food_y=300 food_y=300
score=0
aaa=[(180, 90),(180, 120),(210, 120),(x,y)] aaa=[(180, 90),(180, 120),(210, 120),(x,y)]
# 背景 # 背景
taxt=pygame.font.Font('neuropol.ttf',18)
background = pygame.image.load('bg.png') background = pygame.image.load('bg.png')
right = pygame.image.load('right.png') right = pygame.image.load('right.png')
left = pygame.image.load('left.png') left = pygame.image.load('left.png')
...@@ -56,6 +58,7 @@ while True: ...@@ -56,6 +58,7 @@ while True:
umb_2=random.randint(0,16) umb_2=random.randint(0,16)
food_x=(umb_1-1)*30 food_x=(umb_1-1)*30
food_y=(umb_2-1)*30 food_y=(umb_2-1)*30
score+=10
else: else:
aaa.pop(0) aaa.pop(0)
...@@ -68,7 +71,9 @@ while True: ...@@ -68,7 +71,9 @@ while True:
screen.blit(body,aaa[i]) screen.blit(body,aaa[i])
# 将果实画上去 # 将果实画上去
screen.blit(food, (food_x, food_y)) screen.blit(food, (food_x, food_y))
info='Score:'+str(score)
Taxt=taxt.render(info,True,(0,0,0))
screen.blit(Taxt,(540,10))
# 刷新画面 # 刷新画面
pygame.display.update() pygame.display.update()
aa.tick(4) aa.tick(4)
\ 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