Package com.szuppe.jakub.common

Examples of com.szuppe.jakub.common.Coordinates2D


   * @param ballMockup
   */
  public void setFromMockup(BallMockup ballMockup)
  {
    this.radius = ballMockup.getRadius();
    this.topLeftCoordinates = new Coordinates2D(ballMockup.getTopLeftCoordinates());
    this.speed = new SpeedVector2D(ballMockup.getSpeed());
    this.acceleration = ballMockup.getAcceleration();
    lastRepaintTime = System.currentTimeMillis();
  }
View Full Code Here


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

    // 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 = new SpeedVector2D(0, 0);
      acceleration = new Acceleration2D(0, 0);
      ballDisplacementVector = new Coordinates2D(0, 0);
    }
    else
    {
      ballDisplacementVector = new Coordinates2D(xballDisplacement, yballDisplacement);
    }
    topLeftCoordinates = topLeftCoordinates.moveAlongVector(ballDisplacementVector);

    SpeedVector2D speedChange = acceleration.countSpeedChange(timeInterval);
    speed.add(speedChange);
View Full Code Here

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

  {
    BricksMockup correctedBricksMockup = new BricksMockup();
    List<BrickMockup> bricksList = bricksMockup.getBricksList();
    for (BrickMockup brickMockup : bricksList)
    {
      Coordinates2D correctedCoordinates = new Coordinates2D(brickMockup.getX(), levelHeight - brickMockup.getY());
      correctedBricksMockup.add(new BrickMockup(correctedCoordinates, brickMockup.getBrickType()));
    }
    return correctedBricksMockup;
  }
View Full Code Here

   * @param levelHeight - maksymalna wartość y, tj. wysokość planszy.
   * @return Poprawioną makietę.
   */
  private PaddleMockup correctPaddleMockup(PaddleMockup paddleMockup, float levelHeight)
  {
    Coordinates2D correctedPaddleCoordinates = new Coordinates2D(paddleMockup.getX(), levelHeight
        - paddleMockup.getY());
    SpeedVector2D correctedSpeed = paddleMockup.getSpeed();
    correctedSpeed.reverseYSpeed();
    Acceleration2D correctedAcceleration = paddleMockup.getRetardation();
    correctedAcceleration.reverseYAcc();
View Full Code Here

   * @param levelHeight - maksymalna wartość y, tj. wysokość planszy.
   * @return Poprawioną makietę.
   */
  private BallMockup correctBallMockup(BallMockup ballMockup, float levelHeight)
  {
    Coordinates2D correctedBallCoordinates = new Coordinates2D(ballMockup.getX(), levelHeight - ballMockup.getY());
    SpeedVector2D correctedSpeed = ballMockup.getSpeed();
    correctedSpeed.reverseYSpeed();
    Acceleration2D correctedAcceleration = ballMockup.getAcceleration();
    correctedAcceleration.reverseYAcc();
    BallMockup correctedBallMockup = new BallMockup(correctedBallCoordinates, ballMockup.getRadius(),
View Full Code Here

  /**
   * @return Współrzędne lewego-górnego roku kwadratu zawierającego platformę.
   */
  public Coordinates2D getTopLeftCoordinates()
  {
    return new Coordinates2D(topLeftCoordinates);
  }
View Full Code Here

  /**
   * @return Współrzędne lewego-górnego roku kwadratu zawierającego piłkę.
   */
  public Coordinates2D getTopLeftCoordinates()
  {
    return new Coordinates2D(topLeftCoordinates);
  }
View Full Code Here

    final List<Coordinates2D> verticesList = verticles.getVerticesList();

    try
    {
      // TOP CHECK
      final Coordinates2D paddleLeftTopCo = verticesList.get(1).moveAlongVector(
          new Coordinates2D(0, radius));
      final Coordinates2D paddleRightTopCo = verticesList.get(2).moveAlongVector(
          new Coordinates2D(0, radius));
      Line2D paddleTop = new Line2D(paddleLeftTopCo, paddleRightTopCo);
      Coordinates2D pointOfIntersection = paddleTop
          .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());
      Coordinates2D displacementFromVelocity = speed.countDisplacement(timeTillCollision);
      Coordinates2D displacementFromAcc = acceleration.countDisplacement(timeTillCollision);
      Coordinates2D displacement = displacementFromVelocity
          .moveAlongVector(displacementFromAcc);
      final Coordinates2D paddleLeftTopCoAfterTime = paddleLeftTopCo
          .moveAlongVector(displacement);
      final Coordinates2D paddleRightTopCoAfterTime = paddleRightTopCo
          .moveAlongVector(displacement);
     
      if (paddleLeftTopCoAfterTime.getX() <= pointOfIntersection.getX()
          && pointOfIntersection.getX() <= paddleRightTopCoAfterTime.getX())
      {
        collisionList.add(new BallWithPaddleCollision(timeTillCollision));
      }
      // END TOP CHECK
    } catch (DoesnotIntersectException e)
View Full Code Here

   * @param timeWhenPaddleWillStop - czas, po którym platforma się zatrzyma.
   */
  private void moveAlongVector(long timeInterval, long timeWhenPaddleWillStop)
  {
    long movementTime = Math.min(timeInterval, timeWhenPaddleWillStop);
    Coordinates2D displacementFromVelocity = speed.countDisplacement(movementTime);
    Coordinates2D displacementFromAcc = acceleration.countDisplacement(movementTime);
    Coordinates2D displacement = displacementFromVelocity
        .moveAlongVector(displacementFromAcc);
    verticles.addToAll(displacement);
  }
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.