: # 蛇类
def __init__(self): # 初始化各种需要的属性 [开始时默认向右/身体块x5]
self.dirction, self.body = pygame.K_RIGHT,...snake,food,clock, scores, isdead = Snake(),Food(),pygame.time.Clock(), 0, False
while True:
for event...()
for rect in snake.body:
pygame.draw.rect(screen, (144, 238, 144), rect)
isdead = snake.is_dead()...', (0, 0, 22))
if food.rect == snake.body[0]: # 当食物rect与蛇头重合,吃掉 -> Snake增加一个Node
scores += 1 # 食物处理.../ 吃到+1分
food.remove()
snake.add_node()
food.set() # 食物投递
pygame.draw.rect(screen, (233, 150, 122),