Beispiel #1
0
 private void DrawStandardPiece(int x, int y,
                                int pixelX, int pixelY)
 {
     spriteBatch.Draw(
         playingPieces, new Rectangle(pixelX, pixelY,
                                      GamePiece.PieceWidth, GamePiece.PieceHeight),
         gameBoard.GetSourceRect(x, y),
         Color.White);
 }
Beispiel #2
0
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);

            // TODO: Add your drawing code here
            if (gameState == GameStates.TitleScreen)
            {
                spriteBatch.Begin();
                spriteBatch.Draw(titleScreen,
                                 new Rectangle(0, 0,
                                               this.Window.ClientBounds.Width,
                                               this.Window.ClientBounds.Height),
                                 Color.White);
                spriteBatch.End();
            }

            if (gameState == GameStates.Playing)
            {
                spriteBatch.Begin();

                spriteBatch.Draw(backgroundScreen,
                                 new Rectangle(0, 0,
                                               this.Window.ClientBounds.Width,
                                               this.Window.ClientBounds.Height),
                                 Color.White);

                for (int x = 0; x < GameBoard.GameBoardWidth; x++)
                {
                    for (int y = 0; y < GameBoard.GameBoardHeight; y++)
                    {
                        int pixelX = (int)gameBoardDisplayOrigin.X +
                                     (x * GamePiece.PieceWidth);
                        int pixelY = (int)gameBoardDisplayOrigin.Y +
                                     (y * GamePiece.PieceHeight);

                        spriteBatch.Draw(
                            playingPieces,
                            new Rectangle(
                                pixelX,
                                pixelY,
                                GamePiece.PieceWidth,
                                GamePiece.PieceHeight),
                            EmptyPiece,
                            Color.White);

                        spriteBatch.Draw(
                            playingPieces, new Rectangle(
                                pixelX,
                                pixelY,
                                GamePiece.PieceWidth,
                                GamePiece.PieceHeight),
                            gameBoard.GetSourceRect(x, y),
                            Color.White);
                    }
                }
                this.Window.Title = playerScore.ToString();

                spriteBatch.End();
            }



            base.Draw(gameTime);
        }