Commit a8643c95 by BellCodeEditor

save project

parent 1f816b4e
Showing with 9 additions and 9 deletions
...@@ -27,7 +27,7 @@ while True: ...@@ -27,7 +27,7 @@ while True:
if event.type == locals.QUIT: if event.type == locals.QUIT:
# 接收到退出事件后退出程序 # 接收到退出事件后退出程序
exit() exit()
if event.type == locals.KEYDOWN: elif event.type == locals.KEYDOWN:
if event.key==locals.K_RIGHT and satheading != 'left': if event.key==locals.K_RIGHT and satheading != 'left':
setheading='right' setheading='right'
snake_head=right snake_head=right
...@@ -41,15 +41,14 @@ while True: ...@@ -41,15 +41,14 @@ while True:
setheading='down' setheading='down'
snake_head=down snake_head=down
x+=30
if satheading=='right': if satheading=='right':
X += 30 x += 30
if satheading=='left': elif satheading=='left':
X -= 30 x -= 30
if satheading=='up': elif satheading=='up':
Y += 30 y -= 30
else: else:
X -= 30 y += 30
position.append((x,y)) position.append((x,y))
position.pop(0) position.pop(0)
# 将背景图画上去 # 将背景图画上去
...@@ -67,4 +66,4 @@ while True: ...@@ -67,4 +66,4 @@ while True:
screen.blit(food, (360, 300)) screen.blit(food, (360, 300))
# 刷新画面 # 刷新画面
pygame.display.update() pygame.display.update()
FPSCLOCK.tick(3) FPSCLOCK.tick(3)
\ No newline at end of file
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