Commit c5db1035 by BellCodeEditor

save project

parent ea75c184
Showing with 12 additions and 10 deletions
......@@ -27,6 +27,7 @@ snake_head = right
apple_x,apple_y = 300,360
score = 0
FPSCLOCK.tick(3)
while True:
for event in pygame.event.get():
......@@ -48,6 +49,14 @@ while True:
snake_head = down
# 设置贪吃蛇的头部坐标
if x > 630:
x = -30
elif x < 0:
x = 660
elif y < 0:
y = 480
elif y > 450:
y = -30
if setheading == "right":
x += 30
elif setheading == "left":
......@@ -57,14 +66,7 @@ while True:
else:
y += 30
position.append((x, y))
#if x > 630:
# x = -30
#if x < 0:
# x = 630
#if y < 0:
# y = 450
#if y > 450:
# y = 0
# 将背景图画上去
screen.blit(background, (0, 0))
......@@ -98,4 +100,4 @@ while True:
# 刷新画面
pygame.display.update()
FPSCLOCK.tick(3)
\ No newline at end of file
FPSCLOCK.tick(5)
\ 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