Tetris.Board.Draw C# (CSharp) Method

Draw() public method

public Draw ( GameTime gameTime ) : void
gameTime GameTime
return void
        public override void Draw(GameTime gameTime)
        {
            Vector2 startPosition;
            // Draw the blocks
            for (int i = 0; i < width; i++)
                for (int j = 0; j < height; j++)
                    if (boardFields[i, j] != FieldState.Free)
                    {
                        startPosition = new Vector2((10 + i) * rectangles[0].Width,
                            (2 + j) * rectangles[0].Height);
                        sBatch.Draw(textures, startPosition, rectangles[BoardColor[i, j]], Color.White);
                    }

            // Draw next figures
            Queue<int>.Enumerator figure = nextFigures.GetEnumerator();
            Queue<int>.Enumerator modification = nextFiguresModification.GetEnumerator();
            for (int i = 0; i < nextFigures.Count; i++)
            {
                figure.MoveNext();
                modification.MoveNext();
                for (int j = 0; j < BlocksCountInFigure; j++)
                {
                    startPosition = rectangles[0].Height * (new Vector2(24, 3 + 5 * i) +
                        Figures[figure.Current, modification.Current, j]);
                    sBatch.Draw(textures, startPosition,
                        rectangles[figure.Current], Color.White);
                }
            }

            base.Draw(gameTime);
        }
    }

Usage Example

Ejemplo n.º 1
0
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);
            spriteBatch.Begin();
            // Draw the background
            spriteBatch.Draw(background, new Rectangle(250, 200, 320, 768), Color.White);
            // Draw the ghost piece
            // currentTetromino?.DrawGhost(spriteBatch, BoardLocation);
            // Draw the board
            gameBoard.Draw(spriteBatch, BoardLocation, texture1px);
            nextBlockBoards.Draw(spriteBatch, nextBlockBoardsLocation, texture1px);
            // Draw Game Info

            // Score
            spriteBatch.DrawString(GameFont, String.Format("Score: {0}", Score), new Vector2(50, 60), Color.White);
            // Level
            spriteBatch.DrawString(GameFont, String.Format("Level: {0}", Level), new Vector2(50, 110), Color.White);
            // Lines
            spriteBatch.DrawString(GameFont, String.Format("Lines: {0}", Lines), new Vector2(50, 160), Color.White);

            player.Draw(spriteBatch, position1);


            if (GameOver)
            {
                // Draw game over screen
                spriteBatch.DrawString(GameFont, "Game Over!\nPress Enter to restart.", new Vector2(50, 210), Color.Red);
            }

            // Display the debug Window
            //DrawDebugWindow(spriteBatch);

            spriteBatch.End();
            base.Draw(gameTime);
        }
All Usage Examples Of Tetris.Board::Draw