Exemplo n.º 1
0
        public void CreateNewPiece(bool createBoth = false)
        {
            var      randGen = new Random();
            Position initPos;

            if (createBoth)
            {
                // Create new current piece
                CurrentPiece = Piece.GetPiece(
                    (PieceType)randGen.Next(typeCount),
                    (PieceRotation)randGen.Next(rotationCount),
                    false
                    );
                initPos           = CurrentPiece.GetInitialPosition();
                CurrentPiece.PosX = (_display.BoardHeightInBlocks() / 2) + initPos.X;
                CurrentPiece.PosY = initPos.Y;
            }
            else
            {
                // Move nextPiece to currentPiece.
                initPos           = nextPiece.GetInitialPosition();
                CurrentPiece      = nextPiece;
                CurrentPiece.PosX = (_display.BoardWidthInBlocks() / 2) + initPos.X;
                CurrentPiece.PosY = initPos.Y;
            }

            nextPiece = Piece.GetPiece(
                (PieceType)randGen.Next(typeCount),
                (PieceRotation)randGen.Next(rotationCount)
                );
        }
Exemplo n.º 2
0
        public Game(IDisplay display)
        {
            _display = display;
            _board   = new Board(display.BoardWidthInBlocks(), display.BoardHeightInBlocks());

            CreateNewPiece(true);
        }