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); }
public void onFallingPiece(FallingPiece fallingPiece) // Tekent de Falling Piece { int dim = fallingPiece.Shape.GetLength(0); for (int y = 0; y < dim; y++) { for (int x = 0; x < dim; x++) { if (fallingPiece.Shape[y, x] != 0) { Color tintColor = BlockColors[fallingPiece.Shape[y, x]]; spriteBatch.Draw(block, new Vector2((int)BoardLocation.X + ((int)fallingPiece.Location.X + x) * BlockSize, (int)BoardLocation.Y + ((int)fallingPiece.Location.Y + y) * BlockSize), tintColor); } } } }