Beispiel #1
0
        private void MoveDirection(Direction direction)
        {
            StopGame();
            int shift = 0;

            switch (direction)
            {
            case Direction.Left:
            case Direction.Right:
                shift = (direction == Direction.Left) ? -1 : 1;
                if (CanMove(shift, 0, current))
                {
                    for (int i = 0; i < 4; i++)
                    {
                        current.pC[i].pX += shift;
                    }
                }
                break;

            case Direction.Rotate:
                Tetromino rotated = current.CopyTetromino();
                rotated.Rotate();
                if (CanMove(shift, 0, rotated))
                {
                    current.Rotate();
                }
                break;

            case Direction.IDown:
                Down(true);
                break;

            case Direction.Down:
                Down();
                break;
            }
            this.Refresh();
        }