Beispiel #1
1
 /** Reset ball to an initial state */
 private void serveBall() {
   mBall.x = getWidth() / 2;
   mBall.y = getHeight() / 2;
   mBall.speed = Ball.SPEED + mBallSpeedModifier;
   mBall.randomAngle();
   mBall.pause();
 }
Beispiel #2
0
 @Override
 public void draw(Canvas c) {
   inner_.dx = this.dx;
   inner_.dy = this.dy;
   inner_.x = this.x;
   inner_.y = this.y;
   super.draw(c);
   inner_.draw(c);
 }
Beispiel #3
0
  protected void handleBottomFastBounce(Paddle paddle, float px, float py) {
    if (mBall.goingDown() == false) return;

    float bx = mBall.x;
    float by = mBall.y + Ball.RADIUS;
    float pbx = px;
    float pby = py + Ball.RADIUS;
    float dyp = by - paddle.getTop();
    float xc = bx + (bx - pbx) * dyp / (pby - by);

    if (by > paddle.getTop()
        && pby < paddle.getTop()
        && xc > paddle.getLeft()
        && xc < paddle.getRight()) {

      mBall.x = xc;
      mBall.y = paddle.getTop() - Ball.RADIUS;
      mBall.bouncePaddle(paddle);
      playSound(mPaddleSFX);
      increaseDifficulty();
    }
  }
Beispiel #4
0
  protected void handleTopFastBounce(Paddle paddle, float px, float py) {
    if (mBall.goingUp() == false) return;

    float tx = mBall.x;
    float ty = mBall.y - Ball.RADIUS;
    float ptx = px;
    float pty = py - Ball.RADIUS;
    float dyp = ty - paddle.getBottom();
    float xc = tx + (tx - ptx) * dyp / (ty - pty);

    if (ty < paddle.getBottom()
        && pty > paddle.getBottom()
        && xc > paddle.getLeft()
        && xc < paddle.getRight()) {

      mBall.x = xc;
      mBall.y = paddle.getBottom() + Ball.RADIUS;
      mBall.bouncePaddle(paddle);
      playSound(mPaddleSFX);
      increaseDifficulty();
    }
  }