示例#1
0
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.Black);

            spriteBatch.Begin();

            // Draw player and cpu bars
            spriteBatch.Draw(playerBar.GetTexture(), new Rectangle(playerBar.GetXposition(), playerBar.GetYposition(), Bar.Width, Bar.Height), Color.White);
            spriteBatch.Draw(cpuBar.GetTexture(), new Rectangle(cpuBar.GetXposition(), cpuBar.GetYposition(), Bar.Width, Bar.Height), Color.White);

            // Draw the ball
            spriteBatch.Draw(ballOutManager.GetBall().GetTexture(), new Rectangle(ballOutManager.GetBall().GetXposition(), ballOutManager.GetBall().GetYposition(), 8, 8), Color.White);

            // Draw the Scrore values
            spriteBatch.DrawString(score.GetFont(), score.GetPlayerScore().ToString(CultureInfo.InvariantCulture), new Vector2(Width / 2 - 40 - 15, 20), Color.White);
            spriteBatch.DrawString(score.GetFont(), score.GetCpuScore().ToString(CultureInfo.InvariantCulture), new Vector2(Width / 2 + 40, 20), Color.White);

            DrawNet();

            if (score.PlayerWin())
            {
                Win();
            }

            if (score.CpuWin())
            {
                GameOver();
            }

            spriteBatch.End();


            base.Draw(gameTime);
        }