Ejemplo n.º 1
0
 public AIInput(Ball theBall, Paddle thePaddle, Viewport theViewport)
     : base(PlayerIndex.One)
 {
     mBall = theBall;
     mPaddle = thePaddle;
     mViewport = theViewport;
 }
Ejemplo n.º 2
0
 public void CheckCollision(Paddle thePaddle)
 {
     if (thePaddle.CollisionRectangle.Intersects(CollisionRectangle))
     {
         bool aMovingRight = (mMovement.X > 0);
         bool aMovingLeft = (mMovement.X < 0);
         bool aLeftOfPaddle = (Position.X < thePaddle.Position.X);
         bool aRightOfPaddle = (Position.X > thePaddle.Position.X);
         if (( aMovingRight && aLeftOfPaddle ) || (aMovingLeft && aRightOfPaddle))
         {
             mMovement.X *= -1;
             mHit.Play();
         }
     }
 }
Ejemplo n.º 3
0
        public void Update(GameTime theGametime, Paddle thePaddleOne, Paddle thePaddleTwo)
        {
            Move(mMovement);

            switch (BoundaryCollisionCheck(true))
            {
                case Direction.Left:
                    {
                        OutOfBounds = Direction.Left;
                        Reset();
                        break;
                    }

                case Direction.Right:
                    {
                        OutOfBounds = Direction.Right;
                        Reset();
                        break;
                    }

                case Direction.Top:
                    {
                        mMovement.Y *= -1;
                        mHit.Play();
                        break;
                    }

                case Direction.Bottom:
                    {
                        mMovement.Y *= -1;
                        mHit.Play();
                        break;
                    }
            }

            CheckCollision(thePaddleOne);
            CheckCollision(thePaddleTwo);
        }
Ejemplo n.º 4
0
 public void StartTwoPlayerGame(PlayerIndex thePlayerOne, PlayerIndex thePlayerTwo)
 {
     mPlayerOnePaddle = new Paddle(mContent, "Sprites/Square", new Input(thePlayerOne), Paddle.PaddlePosition.Left);
     mPlayerTwoPaddle = new Paddle(mContent, "Sprites/Square", new Input(thePlayerTwo), Paddle.PaddlePosition.Right);
 }
Ejemplo n.º 5
0
 public void StartOnePlayerGame(PlayerIndex thePlayerOne)
 {
     mPlayerOnePaddle = new Paddle(mContent, "Sprites/Square", new Input(thePlayerOne), Paddle.PaddlePosition.Left);
     mPlayerTwoPaddle = new Paddle(mContent, "Sprites/Square", new Input(thePlayerOne), Paddle.PaddlePosition.Right);
     mPlayerTwoPaddle.mInput = new AIInput(mBall, mPlayerTwoPaddle, mViewport);
 }
Ejemplo n.º 6
0
 public void StartTwoPlayerGame(PlayerIndex thePlayerOne, PlayerIndex thePlayerTwo)
 {
     mPlayerOnePaddle = new Paddle(mContent, "Sprites/Square", new Input(thePlayerOne), Paddle.PaddlePosition.Left);
     mPlayerTwoPaddle = new Paddle(mContent, "Sprites/Square", new Input(thePlayerTwo), Paddle.PaddlePosition.Right);
 }
Ejemplo n.º 7
0
 public void StartOnePlayerGame(PlayerIndex thePlayerOne)
 {
     mPlayerOnePaddle        = new Paddle(mContent, "Sprites/Square", new Input(thePlayerOne), Paddle.PaddlePosition.Left);
     mPlayerTwoPaddle        = new Paddle(mContent, "Sprites/Square", new Input(thePlayerOne), Paddle.PaddlePosition.Right);
     mPlayerTwoPaddle.mInput = new AIInput(mBall, mPlayerTwoPaddle, mViewport);
 }