
Walls and Collisions
This piece of code uses collision detection to tell if the snake has bumped into another object such as the walls or the island. You will use an if statement with the isEmpty function to check that the space the snake is moving into is empty and if it is not empty, stop the snake from moving.
See the Pen GB7 M2 by Walker Books UK (@walkerbooks) on CodePen.