예제 #1
0
    protected double salt(double angle, Paddle paddle) {
      int cx = paddle.centerX();
      double halfWidth = paddle.getWidth() / 2;
      double change = 0.0;

      if (goingUp()) change = SALT * ((cx - x) / halfWidth);
      else change = SALT * ((x - cx) / halfWidth);

      return boundAngle(angle, change);
    }
예제 #2
0
 protected float applyCenterHitBonus(Paddle paddle) {
   int cx = paddle.centerX();
   float newSpeed;
   float centerBonusIndicator = Math.abs(cx - this.x);
   if (centerBonusIndicator <= CENTER_HIT_CONSTANT) {
     newSpeed = this.speed * 2;
   } else {
     newSpeed = this.speed;
   }
   return newSpeed;
 }
예제 #3
0
  @Override
  public boolean onTrackballEvent(MotionEvent event) {
    if (!gameRunning()) return false;

    if (mBlue.player == false) {
      mBlue.player = true;
      mBlue.destination = mBlue.centerX();
    }

    switch (event.getAction()) {
      case MotionEvent.ACTION_MOVE:
        mBlue.destination =
            (int)
                Math.max(
                    0, Math.min(getWidth(), mBlue.destination + SCROLL_SENSITIVITY * event.getX()));
        break;
    }

    return true;
  }