protected override void UpdateWorld() { if (GamePad.ButtonBackClicked()) { this.Exit(); } if (GamePad.ButtonAClicked()) { if (mBall.IsInAutoDrawSet()) { mMissed++; } mBall.InitializeNewBall(); } if (GamePad.ButtonBClicked()) { mBall.RemoveFromAutoDrawSet(); mMissed++; } float userLeft = GamePad.Triggers.Left; float userRight = GamePad.Triggers.Right; for (int i = 0; i < kNumPaddlesPerSide; i++) { if ((mLeftPaddles[i].Update(userLeft, mBall)) || (mRightPaddles[i].Update(userRight, mBall))) { mHit++; } } if (mBall.IsInAutoDrawSet()) { mBall.Update(); EchoToBottomStatus("Ball position: " + mBall.Center); } else { EchoToBottomStatus("No Ball in the world"); } EchoToTopStatus("Hit: " + mHit + " Missed:" + mMissed); }
private bool UpdateCollisionWithBall(MyBall ball) { bool collided = (ball.IsInAutoDrawSet()) && Collided(ball); if (collided) { ball.RemoveFromAutoDrawSet(); } return(collided); }