Commit 834d6e0c by BellCodeEditor

save project

parent 96be9e2b
Showing with 4 additions and 5 deletions
......@@ -26,7 +26,7 @@ position = [(180, 90), (180, 120), (210, 120), (x, y)]
setheading = "right"
snake_head = right
score = 2
score = 0
while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
......@@ -62,11 +62,9 @@ while True:
n2 = random.randint(1,16)
apple_x = n1 * 30 - 30
apple_y = n2 * 30 - 30
score = score * score
score += 1
else:
position.pop(0)
if x < 0 or x >640 or y < 0 or y > 450:
exit()
screen.blit(background, (0, 0))
# 将贪吃蛇的头画上去
screen.blit(snake_head, position[-1])
......@@ -78,7 +76,7 @@ while True:
screen.blit(food, (apple_x, apple_y))
info = 'Score' + str(score)
text = my_font.render(info,True,(0,0,0))
screen.blit(text,(0,0))
screen.blit(text,(540,10))
# 刷新画面
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