private void MoveCloserTo(int point)
        {
            var middleOfBar = cpuBar.GetYposition() + BarHeight / 2;

            if (middleOfBar < point)
            {
                cpuBar.MoveDown();
            }
            if (middleOfBar > point)
            {
                cpuBar.MoveUp();;
            }
        }
Exemple #2
0
 public Boolean IsYcollision(Bar bar)
 {
     return(yPosition < bar.GetYposition() + BarHeight && yPosition > bar.GetYposition());
 }
Exemple #3
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);
        }
Exemple #4
0
 public Boolean IsYcollision(Bar bar)
 {
     return yPosition < bar.GetYposition() + BarHeight && yPosition > bar.GetYposition();
 }