public void Reset() { SnakePiece head = Head(); head.direction = SnakePiece.Direction.Stopped; head.squarex = 100; head.squarey = 100; snake.Clear(); snake.Add(head); }
public void Grow() { SnakePiece tail = snake[snake.Count - 1]; if (tail.direction == SnakePiece.Direction.Up) { snake.Add(new SnakePiece(tail.squarex, tail.squarey + tail.height, tail.width, tail.height)); } if (tail.direction == SnakePiece.Direction.Down) { snake.Add(new SnakePiece(tail.squarex, tail.squarey - tail.height, tail.width, tail.height)); } if (tail.direction == SnakePiece.Direction.Right) { snake.Add(new SnakePiece(tail.squarex - tail.width, tail.squarey, tail.width, tail.height)); } if (tail.direction == SnakePiece.Direction.Left) { snake.Add(new SnakePiece(tail.squarex + tail.width, tail.squarey, tail.width, tail.height)); } }