/// <summary> /// Constructor. /// </summary> /// <param name="snakeHead"></param> public SnakeBodyPart(SnakeHead snakeHead) { _gameBoardWidthPixels = snakeHead.GameBoardWidthPixels; _gameBoardHeightPixels = snakeHead.GameBoardHeightPixels; _width = snakeHead.Width; _height = snakeHead.Height; _directionOfTravel = snakeHead.DirectionOfTravel; if (snakeHead.DirectionOfTravel == Direction.Right) { _xPosition = snakeHead.XPosition - _width; _yPosition = snakeHead.YPosition; } else if (snakeHead.DirectionOfTravel == Direction.Left) { _xPosition = snakeHead.XPosition + _width; _yPosition = snakeHead.YPosition; } else if (snakeHead.DirectionOfTravel == Direction.Down) { _xPosition = snakeHead.XPosition; _yPosition = snakeHead.YPosition - _height; } else if (snakeHead.DirectionOfTravel == Direction.Up) { _xPosition = snakeHead.XPosition; _yPosition = snakeHead.YPosition + _height; } UpdatePosition(); }
/// <summary> /// Constructor. /// </summary> public Snake(double gameBoardWidthPixels, double gameBoardHeightPixels) { _gameBoardWidthPixels = gameBoardWidthPixels; _gameBoardHeightPixels = gameBoardHeightPixels; TheSnakeHead = new SnakeHead(gameBoardWidthPixels, gameBoardHeightPixels, Constants.DefaultXposition, Constants.DefaultYposition, Constants.DefaultDirection); TheSnakeEye = new SnakeEye(gameBoardWidthPixels, gameBoardHeightPixels, Constants.DefaultXposition, Constants.DefaultYposition, Constants.DefaultDirection); _snakeBody = new ObservableCollection <SnakeBodyPart>(); _updatingSnake = false; }