Esempio n. 1
0
  public static Point2D getRandomPointAroundObj(WorldObject obj) {
    double radius =
        (Math.sqrt((obj.getWidth() * obj.getWidth()) + (obj.getHeight() * obj.getHeight()))) / 2d;
    radius *= 1.3d;

    return getRandomPointAroundObj(obj, radius);
  }
Esempio n. 2
0
  public static void setOffsetAroundOrigin(
      WorldObject origin, WorldObject target, double averageRadius) {
    Point2D random = getRandomPointAroundObj(origin, averageRadius);

    Point2D position =
        new Point2D.Double(
            origin.getOffset().getX() + random.getX(), origin.getOffset().getY() + random.getY());

    target.setOffset(position);
  }
Esempio n. 3
0
  public static Point2D getRandomPointAroundObj(WorldObject obj, double averageRadius) {

    double randomAngle = randomGen.nextDouble() * 2d * Math.PI;
    double randomOffset = ((randomGen.nextDouble() - 0.5d) * 0.2d) + 1d;
    double offsetY = (Math.sin(randomAngle) * averageRadius) * randomOffset;
    double offsetX = (Math.cos(randomAngle) * averageRadius) * randomOffset;

    offsetX += obj.getBounds().getCenterX();
    offsetY += obj.getBounds().getCenterY();
    return new Point2D.Double(offsetX, offsetY);
  }
Esempio n. 4
0
 @Override
 protected void activityStarted() {
   obj.destroy();
 }