private bool UpdateCollisionWithBall(MyBall ball) { bool collided = (ball.IsInAutoDrawSet()) && Collided(ball); if (collided) { ball.RemoveFromAutoDrawSet(); } return(collided); }
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); }
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(); }
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(); }
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); }