private void drawDebug(SpriteBatch spriteBatch) { foreach (KeyValuePair <Point, Rectangle> boundingBox in boundingBoxes) { spriteBatch.Draw(ComponentLocator.FindTexture("Reset"), boundingBox.Value, Color.Red); } }
public void Draw(SpriteBatch spriteBatch, GameTime gameTime) { if (!board.IsGameOver()) { spriteBatch.DrawString(ComponentLocator.FindFont("arial"), "Current Turn: " + GetPlayerTurnText(), new Vector2(10, 10), Color.White); } else { string text = ""; if (board.GetGameState() == Board.State.Draw) { text = "Draw"; } else if (board.GetGameState() == Board.State.PlayerXWins) { text = "Player X Wins"; } else if (board.GetGameState() == Board.State.PlayerOWins) { text = "Player O Wins"; } Point textSize = ComponentLocator.FindFont("arial").MeasureString(text).ToPoint(); Point position = new Point(screenCenter.X, screenCenter.Y) - textSize / new Point(2, 2) + new Point(0, -150); spriteBatch.DrawString(ComponentLocator.FindFont("arial"), text, position.ToVector2(), Color.White); } drawLines(spriteBatch); drawBoard(spriteBatch, board); spriteBatch.Draw(ComponentLocator.FindTexture("Reset"), reset, Color.White); //drawDebug(spriteBatch); }
private void drawSingleLine(SpriteBatch spriteBatch, Vector2 lineStart, Vector2 lineEnd) { Vector2 edge = lineEnd - lineStart; float angle = (float)Math.Atan2(edge.Y, edge.X); spriteBatch.Draw( ComponentLocator.FindTexture("Line"), new Rectangle((int)lineStart.X, (int)lineStart.Y, (int)edge.Length(), 2), null, Color.Red, angle, new Vector2(0, 0), SpriteEffects.None, 0 ); }
private void drawBoard(SpriteBatch spriteBatch, Board board) { char[,] nodes = board.GetBoard(); Vector2 margin = new Vector2(screenCenter.X - (64 * 3 / 2), screenCenter.Y - (64 * 3 / 2)); Vector2 padding = new Vector2(2, 2); for (int x = 0; x < 3; x++) { for (int y = 0; y < 3; y++) { char player = nodes[x, y]; Vector2 position = new Vector2(64 * y, 64 * x); Vector2 finalPosition = position + margin; if (player != ' ') { spriteBatch.Draw(ComponentLocator.FindTexture(player.ToString()), new Rectangle(finalPosition.ToPoint(), new Point(64, 64)), Color.White); } } } }