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); }
/// <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 == GameState.TitleScreen) { spriteBatch.Begin(); spriteBatch.Draw(titleScreen, new Rectangle(0, 0, this.Window.ClientBounds.Width, this.Window.ClientBounds.Height), Color.White); spriteBatch.End(); } if (gameState == GameState.Playing) { spriteBatch.Begin(); spriteBatch.Draw(background, 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 * GamePieces.PieceWidth); int pixelY = (int)gameBoardDisplayOrigin.Y + (y * GamePieces.PieceHeight); spriteBatch.Draw( playingPieces, new Rectangle( pixelX, pixelY, GamePieces.PieceWidth, GamePieces.PieceHeight), EmptyPiece, Color.White); spriteBatch.Draw( playingPieces, new Rectangle( pixelX, pixelY, GamePieces.PieceWidth, GamePieces.PieceHeight), gameBoard.GetSourceRect(x, y), Color.White); } } this.Window.Title = playerScore.ToString(); spriteBatch.End(); } base.Draw(gameTime); }