Commit d9672186 by BellCodeEditor

save project

parent 31674e53
Showing with 11 additions and 5 deletions
......@@ -23,7 +23,13 @@ position = [(180, 90), (180, 120), (210, 120), (x, y)]
setheading = "right"
snake_head = right
def xy():
x=random.randint(1,22)
y=random.randint(1,16)
x*=30
y*=30
return x,y
ax,ay=xy()
while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
......@@ -52,9 +58,8 @@ while True:
y -= 30
else:
y += 30
if x==ax and y==ay:
ax=random.randint(0,660)
ay=random.randint(0,480)
if x==ax and y==ay:
ax,ay=xy()
position.append((x, y))
position.pop(0)
# 将背景图画上去
......@@ -66,7 +71,7 @@ if x==ax and y==ay:
screen.blit(body, position[i])
# 将果实画上去
screen.blit(food, (ax, ay))
screen.blit(food,(ax,ay))
# 刷新画面
pygame.display.update()
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