Commit 39bfe23e by BellCodeEditor

save project

parent f9c9ce55
Showing with 5 additions and 4 deletions
...@@ -26,6 +26,7 @@ position = [(180, 90), (180, 120), (210, 120), (x, y)] ...@@ -26,6 +26,7 @@ position = [(180, 90), (180, 120), (210, 120), (x, y)]
setheading = "right" setheading = "right"
snake_head = right snake_head = right
score = 0 score = 0
r = 3
while True: while True:
for event in pygame.event.get(): for event in pygame.event.get():
...@@ -47,8 +48,8 @@ while True: ...@@ -47,8 +48,8 @@ while True:
snake_head = down snake_head = down
# 设置贪吃蛇的头部坐标 # 设置贪吃蛇的头部坐标
if x<0 or x>630 or y<0 or y >450 : if x<0 or x>630 or y<0 or y >450 :
exit() exit()
if setheading == "right": if setheading == "right":
x += 30 x += 30
elif setheading == "left": elif setheading == "left":
...@@ -79,4 +80,4 @@ while True: ...@@ -79,4 +80,4 @@ while True:
screen.blit(food, (apple_x, apple_y)) screen.blit(food, (apple_x, apple_y))
# 刷新画面 # 刷新画面
pygame.display.update() pygame.display.update()
FPSCLOCK.tick(3) FPSCLOCK.tick(7)
\ No newline at end of file \ 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