Пример #1
0
        public static MoveContext GetRotationContext(Tetromino tetromino)
        {
            var newMatrix        = GetRotatedMatrix(tetromino.BodyMatrix);
            var rotatedPositions = Tetromino.GetPositions(tetromino.TopLeft, newMatrix);

            return(new MoveContext(tetromino.TopLeft, rotatedPositions, newMatrix));
        }
Пример #2
0
        public static MoveContext GetMoveContext(Tetromino tetromino, MovementDirection direction, int speed)
        {
            PositionInfo newTopLeft = tetromino.TopLeft;

            if (direction == MovementDirection.Down)
            {
                newTopLeft = new PositionInfo(tetromino.TopLeft.X, tetromino.TopLeft.Y + speed);
            }
            else if (direction == MovementDirection.Left)
            {
                newTopLeft = new PositionInfo(tetromino.TopLeft.X - speed, tetromino.TopLeft.Y);
            }
            else if (direction == MovementDirection.Right)
            {
                newTopLeft = new PositionInfo(tetromino.TopLeft.X + speed, tetromino.TopLeft.Y);
            }

            var context = new MoveContext(newTopLeft, Tetromino.GetPositions(newTopLeft, tetromino.BodyMatrix), tetromino.BodyMatrix);

            return(context);
        }