private bool CheckCollision(StateOfLocation[,] oldGameBoard, List <Point> newSnakePosition) { Point snakeHeadPosition = newSnakePosition[0]; //Does the snake run out of the game area? if (snakeHeadPosition.Y < 0 || snakeHeadPosition.Y > height - 1 || snakeHeadPosition.X < 0 || snakeHeadPosition.X > width - 1) { return(true); } //Does the snake run into itself? if (oldGameBoard[snakeHeadPosition.X, snakeHeadPosition.Y] == StateOfLocation.Snake) { return(true); } //Does the snake run into food? if (oldGameBoard[snakeHeadPosition.X, snakeHeadPosition.Y] == StateOfLocation.Food) { snake.Eat(); score++; hasEaten = true; food.ChangeFoodPosition(width, height, gameBoard); return(false); } //Does the snake go into empty space? return(false); }