public static void TryMoveSnake(char[,] field, Snake snake, Point headPoint, Point tail, Point prize, char directionChar, Point newPoint) { if (snake.BodyPoints.Any(p => p.PX == newPoint.PX && p.PY == newPoint.PY)) { throw new SuddenDeathException(); } field[headPoint.PY, headPoint.PX] = '8'; snake.AddPoint(newPoint, (short)field.GetLength(0), (short)field.GetLength(1)); headPoint = snake.BodyPoints.Last(); field[headPoint.PY, headPoint.PX] = directionChar; }
private void initPositions() { for (int i = 1; i < 10; i++) { snake.AddPoint(new Point(i, 20)); } LoadMap(level); food.ClearLocations(); food.AddPoint(GetRandomPoint()); }