Commit c3f5a0ae by BellCodeEditor

save project

parent 248cd42d
Showing with 10 additions and 7 deletions
...@@ -23,10 +23,9 @@ position = [(180, 90), (180, 120), (210, 120), (x, y)] ...@@ -23,10 +23,9 @@ position = [(180, 90), (180, 120), (210, 120), (x, y)]
setheading = "right" setheading = "right"
snake_head = right snake_head = right
nam1=random.randint(0,22)
nam2=random.randint(0,16) apple_x = 360
apple_x = 30*nam1-30 apple_y = 300
apple_y = 30*nam2-30
while True: while True:
for event in pygame.event.get(): for event in pygame.event.get():
...@@ -57,9 +56,13 @@ while True: ...@@ -57,9 +56,13 @@ while True:
else: else:
y += 30 y += 30
position.append((x, y)) position.append((x, y))
if x == apple_y and y == apple_y: print("x="+str(x),"y="+str(y))
apple_x = 30*nam1-30 print("apple_x="+str(apple_y),"apple_y="+str(apple_y))
apple_y = 30*nam2-30 if x == apple_x and y == apple_y:
num1 = random.randint(0,22)
num2 = random.randint(0,16)
apple_x = 30*num1-30
apple_y = 30*num2-30
else: else:
position.pop(0) position.pop(0)
# 将背景图画上去 # 将背景图画上去
......
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