Example #1
0
        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);
        }
Example #2
0
 public override void Draw(SpriteBatch spriteBatch, GameTime gameTime)
 {
     spriteBatch.DrawString(ComponentLocator.FindFont("arial"), text, position, Color.Black);
 }
Example #3
0
 public void CalculateArea()
 {
     area = new Rectangle(position.ToPoint(), ComponentLocator.FindFont("arial").MeasureString(text).ToPoint());
 }