Package com.szuppe.jakub.common

Examples of com.szuppe.jakub.common.Coordinates2D


  /**
   * @return Półprostą przedstawiającą tor ruchu piłki.
   */
  public Ray2D getMovementRay()
  {
    Coordinates2D start = new Coordinates2D(coordinates);
    Coordinates2D end = coordinates.moveAlongVector(speed.countDisplacement(1000));
    return new Ray2D(start, end);
  }
View Full Code Here


  /**
   * @return Współrzędne środka piłki.
   */
  public Coordinates2D getCoordinates()
  {
    return new Coordinates2D(coordinates);
  }
View Full Code Here

   *
   * @param movementTime - czas.
   */
  private void moveAlongVector(long movementTime)
  {
    Coordinates2D displacementFromVelocity = speed.countDisplacement(movementTime);
    Coordinates2D displacementFromAcc = acceleration.countDisplacement(movementTime);
    Coordinates2D displacement = displacementFromVelocity
        .moveAlongVector(displacementFromAcc);
    coordinates.add(displacement);
  }
View Full Code Here

  /**
   * @return Początkowe współrzędne piłki.
   */
  public Coordinates2D getStartCoordinates()
  {
    return new Coordinates2D(startCoordinates);
  }
View Full Code Here

   * @return Makietę piłki.
   */
  public BallMockup getBallMockup()
  {
    final int ballRadius = ball.getRadius();
    final Coordinates2D topLeftBallCoordinates = ball.getCoordinates();
    topLeftBallCoordinates.add(new Coordinates2D(-ballRadius, ballRadius));
    return new BallMockup(topLeftBallCoordinates, ballRadius, ball.getSpeed(), ball.getAcceleration());
  }
View Full Code Here

  /**
   * @return Makietę platformy.
   */
  public PaddleMockup getPaddleMockup()
  {
    final Coordinates2D topLeftPaddleCoordinates = new Coordinates2D(paddle.getMinX(), paddle.getMaxY());
    return new PaddleMockup(topLeftPaddleCoordinates, paddle.getSpeed(), paddle.getAcceleration());
  }
View Full Code Here

   */
  public void move()
  {
    long timeInterval = System.currentTimeMillis() - lastRepaintTime;
    lastRepaintTime = System.currentTimeMillis();
    Coordinates2D paddleDisplacementVector;

    // s = v * t + (a * t^2)/2
    float xballDisplacement = (speed.getXSpeed() * timeInterval)
        + (0.5f * acceleration.getxAcc() * timeInterval * timeInterval);
    float yballDisplacement = (speed.getYSpeed() * timeInterval)
        + (0.5f * acceleration.getyAcc() * timeInterval * timeInterval);
    if (Math.abs(speed.getXSpeed()) < Math.abs(0.5f * acceleration.getxAcc() * timeInterval)
        || Math.abs(speed.getYSpeed()) < Math.abs(0.5f * acceleration.getyAcc() * timeInterval))
    {
      speed.zero();
      acceleration.zero();
      paddleDisplacementVector = new Coordinates2D(0, 0);
    }
    else
    {
      paddleDisplacementVector = new Coordinates2D(xballDisplacement, yballDisplacement);
    }
    topLeftCoordinates = topLeftCoordinates.moveAlongVector(paddleDisplacementVector);
    SpeedVector2D speedChange = acceleration.countSpeedChange(timeInterval);
    speed.add(speedChange);
  }
View Full Code Here

        .getRadius());
    Side sides[] = { Side.BOTTOM, Side.RIGHT, Side.TOP, Side.LEFT, Side.CORNER,
        Side.CORNER, Side.CORNER, Side.CORNER };
    Ray2D ballMovementRay = ball.getMovementRay();
    SpeedVector2D ballSpeed = ball.getSpeed();
    Coordinates2D pointOfIntersection;
    for (LineSegment2D brickLineSegment : brickLineSegments)
    {
      try
      {
        pointOfIntersection = brickLineSegment.intersectionPoint(ballMovementRay);
        double distance = Math.sqrt(Math.pow(
            pointOfIntersection.getX() - ball.getX(), 2)
            + Math.pow(pointOfIntersection.getY() - ball.getY(), 2));
        long timeTillCollision = (long) (distance / ballSpeed.getSpeedValue());
        Side side = sides[brickLineSegments.indexOf(brickLineSegment)];
        collisionList.add(new BallWithBrickCollision(timeTillCollision, this, side));
      } catch (DoesnotIntersectException e)
      {
View Full Code Here

  /**
   * @return Współrzędne lewego-górnego rogu.
   */
  public Coordinates2D getTopLeftCornerCoordinates()
  {
    return new Coordinates2D(topLeftCoordinates);
  }
View Full Code Here

  /**
   * @return Współrzędne prawego-górnego rogu.
   */
  public Coordinates2D getTopRightCornerCoordinates()
  {
    return new Coordinates2D(
        (float) (topLeftCoordinates.getX() + dimension.getWidth()),
        topLeftCoordinates.getY());
  }
View Full Code Here

TOP

Related Classes of com.szuppe.jakub.common.Coordinates2D

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.