的粉色实心圆
pygame.draw.circle(screen, color, position, radius, width)
# 随机产生食物
def update(self, screen, enlarge..., snack):
if enlarge:
self.item = np.random.randint(1, BOARDWIDTH – 2), np.random.randint(1, BOARDHEIGHT...# 初始方向竖直向上
self.item = [(3, 25), (2, 25), (1, 25), (1, 24), ]
self.x = 0
self.y = -1
def move(self, enlarge...):
# enlarge 标记贪吃蛇有没有吃到食物
if not enlarge:
# 吃到食物删除尾部元素
self.item.pop()
# 新蛇头的坐标为旧蛇头坐标加上移动方向的位移
head =...= snack.eat_food(food)
food.update(screen, enlarge, snack)
snack.move(enlarge)
is_fail = game_over(snack