예제 #1
0
파일: AIInput.cs 프로젝트: Gevil/Projects
 public AIInput(Ball theBall, Paddle thePaddle, Viewport theViewport)
     : base(PlayerIndex.One)
 {
     mBall = theBall;
     mPaddle = thePaddle;
     mViewport = theViewport;
 }
예제 #2
0
파일: Ball.cs 프로젝트: Gevil/Projects
 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();
         }
     }
 }
예제 #3
0
파일: Ball.cs 프로젝트: Gevil/Projects
        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);
        }
예제 #4
0
파일: Gameplay.cs 프로젝트: Gevil/Projects
 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);
 }
예제 #5
0
파일: Gameplay.cs 프로젝트: Gevil/Projects
 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);
 }
예제 #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);
 }
예제 #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);
 }