Ejemplo n.º 1
0
        public void onNextPiece(NextPiece nextPiece) // Tekent de Next Piece met het canvas aan de zijkant
        {
            int   dim          = nextPiece.Shape.GetLength(0);
            int   DrawPosition = (dim * BlockSize) / 2;
            float Bx           = (float)ScreenWidth * (float)0.75 - DrawPosition;
            float By           = (float)ScreenHeight * (float)0.05 + (47 + 16) - DrawPosition;

            if (dim == 2)
            {
                By = (float)ScreenHeight * (float)0.05 + 47 - DrawPosition;
            }

            float Cx = (float)ScreenWidth * (float)0.75 - 76;
            float Cy = (float)ScreenHeight * (float)0.05;

            spriteBatch.Draw(NextPieceCanvas, new Vector2(Cx, Cy), Color.White);

            for (int y = 0; y < dim; y++)
            {
                for (int x = 0; x < dim; x++)
                {
                    if (nextPiece.Shape[y, x] != 0)
                    {
                        Color tintColor = BlockColors[nextPiece.Shape[y, x]];

                        //spriteBatch.Draw(block, new Vector2(460 + (x * BlockSize) - DrawPosition, 45 + (y * BlockSize)), tintColor);
                        spriteBatch.Draw(block, new Vector2(Bx + (x * BlockSize), By + (y * BlockSize)), tintColor);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public Board(SpriteBatch _spriteBatch, Texture2D _block, Texture2D _NextPieceCanvas, int _ScreenWidth, int _ScreenHeight, int _GridWidth, int _GridHeight, int _BlockSize)
        {
            ScreenWidth  = _ScreenWidth;
            ScreenHeight = _ScreenHeight;

            GridWidth  = _GridWidth;
            GridHeight = _GridHeight;
            BlockSize  = _BlockSize;

            spriteBatch     = _spriteBatch;
            block           = _block;
            NextPieceCanvas = _NextPieceCanvas;

            grid         = new Grid(GridWidth, GridHeight, BlockSize);
            shape        = new Shape();
            Rand         = new Random();
            nextPiece    = new NextPiece();
            fallingPiece = new FallingPiece();

            grid.GameGrid = grid.ResetGrid();
            SpawnNext();
            SpawnCurrent();

            TimeReset = false;


            Score = 0;

            drawVisitor = new DrawVisitor(spriteBatch, shape.BlockColors, block, grid.Location, BlockSize, GridWidth, GridHeight, ScreenWidth, ScreenHeight, NextPieceCanvas);
        }