Beispiel #1
0
 public AIInput(Ball theBall, Paddle thePaddle, Viewport theViewport)
     : base(PlayerIndex.One)
 {
     mBall = theBall;
     mPaddle = thePaddle;
     mViewport = theViewport;
 }
Beispiel #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();
         }
     }
 }
Beispiel #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);
        }
Beispiel #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);
 }
Beispiel #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);
 }
Beispiel #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);
 }
Beispiel #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);
 }