コード例 #1
0
 /**
  * Calculates a vertical value for a quadratic function using Lagrange's from of the interpolation
  * polynomial The formula takes a flipped Y axis in consideration
  *
  * @param x the horizontal coordinate
  * @return a new value for Y
  */
 private double calcY(double x) {
   double x0 = startPoint.getX();
   double x1 = midPoint.getX();
   double x2 = endPoint.getX();
   double l0 = ((x - x1) * (x - x2)) / ((x0 - x1) * (x0 - x2));
   double l1 = ((x - x0) * (x - x2)) / ((x1 - x0) * (x1 - x2));
   double l2 = ((x - x0) * (x - x1)) / ((x2 - x0) * (x2 - x1));
   return startPoint.getY() * l0 + midPoint.getY() * l1 + endPoint.getY() * l2;
 }
コード例 #2
0
 @Override
 public void fire(
     final Position shipPosition,
     final PlayerID playerId,
     final Rotation rotation,
     final float timeElapsed) {
   cooldown = cooldown - timeElapsed;
   if (cooldown < 0) {
     cooldown = cooldown + INIT_COOLDOWN;
     this.getBulletManager()
         .addBullet(
             new BasicBullet(
                 shipPosition.getX(),
                 shipPosition.getY(),
                 BULLET_WIDTH,
                 BULLET_HEIGHT,
                 playerId,
                 new Rotation(rotation.getAngle() + currentAngle),
                 BULLET_DAMAGE));
     currentAngle = currentAngle + ANGLE_STEP;
   }
 }