예제 #1
0
        private bool UpdateCollisionWithBall(MyBall ball)
        {
            bool collided = (ball.IsInAutoDrawSet()) && Collided(ball);

            if (collided)
            {
                ball.RemoveFromAutoDrawSet();
            }
            return(collided);
        }
예제 #2
0
        public bool UpdatePaddles(float rotation, MyBall ball)
        {
            bool hit = false;
            int  i   = 0;

            while ((!hit) && (i < mPaddles.Length))
            {
                hit = mPaddles[i].Update(rotation, ball);
                i++;
            }
            return(hit);
        }
예제 #3
0
        protected override void InitializeWorld()
        {
            World.SetWorldCoordinate(new Vector2(0, 0), kWorldWidth);
            mHit = mMissed = 0;

            mLeftPaddles = new PaddleSet(PaddleSet.PaddleSetType.eLeftSet,
                                         3,         // number of paddles
                                         15,        // x position of the paddles
                                         10,        // initial y position
                                         15);       // y distance between the paddles

            mRightPaddles = new PaddleSet(PaddleSet.PaddleSetType.eRightSet,
                                          4,       // number of paddles
                                          70,      // x position of the paddles
                                          15,      // initial y positions
                                          8);      // y distance between the paddles

            mBall = new MyBall();
        }
예제 #4
0
        protected override void InitializeWorld()
        {
            World.SetWorldCoordinate(new Vector2(0, 0), kWorldWidth);
            mHit = mMissed = 0;

            mLeftPaddles = new Paddle[kNumPaddlesPerSide];
            float y = kYDist;
            int   i = 0;

            while (i < kNumPaddlesPerSide)
            {
                // allocate the left/right paddles
                mLeftPaddles[i] = new Paddle(new Vector2(kLeftPosition, y));

                i++;
                y += kYDist;
            }
            mBall = new MyBall();
        }
예제 #5
0
        public bool Update(float userInput, MyBall ball)
        {
            float rotateTo = RotatedAngle(userInput);

            // update the rotine stuff
            bool ballDead = UpdateCollisionWithBall(ball);

            // Now come to handle our own state
            switch (mCurrentPaddleState)
            {
            case PaddleState.PaddleAtRest:
                UpdatePaddleFromRest(rotateTo);
                break;

            case PaddleState.PaddleReturning:
                UpdatePaddleFromDownMotion(rotateTo);
                break;
            }

            mShowDir.SetEndPoints(Center, Center + (3 * FrontDirection), 0.8f);
            mShowDir.Color = Color.Black;

            return(ballDead);
        }