I tried to add the ability of the snake to pass through the walls. There were several problems.

  • The snake loses one part of the body as it passes through the wall, Until it disappears.

  • Food becomes inactive.

  • If the length of the snake is less than 2 through the walls, it passes but not
    come back on the other side.

Solutions are probably completely crooked, because sometimes nothing works at all. Please indicate the errors, I will be grateful for the example how it was necessary b.

    1 answer 1

    throughWall() needs to be called after the coordinates of the snake have already been rebuilt.

    There is no access to your feed. HTML and CSS, for example, took from the question of acceleration.

    Example: JSFiddle .

    • Thanks for the help. Your answers helped. I did not notice that there is no access to the feed. ( - pridan