Android Open Source - FallingBall Vector






From Project

Back to project page FallingBall.

License

The source code is released under:

GNU General Public License

If you think the Android project FallingBall listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package edu.fmi.android.brickpong.utils;
//  w  ww.ja  v  a 2s  .c  o  m
public class Vector {

  /**
   * {@value}
   */
  private static final int ORIENTATION_Y_BORDER_TOP = 1;

  /**
   * {@value}
   */
  private static final int ORIENTATION_X_BORDER_TOP = 0;

  /**
   * {@value}
   */
  private static final int ORIENTATION_Y_BORDER_LEFT = 0;

  /**
   * {@value}
   */
  private static final int ORIENTATION_X_BORDER_LEFT = 1;

  /**
   * {@value}
   */
  private static final int ORIENTATION_Y_BORDER_RIGHT = 0;

  /**
   * {@value}
   */
  private static final int ORIENTATION_X_BORDER_RIGHT = -1;

  public float x;

  public float y;

  public Vector(final float x, final float y) {
    this.x = x;
    this.y = y;
  }

  public Vector() {
    this(0, 0);
  }

  public float dotProduct(final Vector other) {
    return this.x * other.x + this.y * other.y;
  }

  public Vector multiply(final float coef) {
    return new Vector(x * coef, y * coef);
  }

  public Vector add(final Vector other) {
    return new Vector(x + other.x, y + other.y);
  }

  public Vector substract(final Vector other) {
    return new Vector(x - other.x, y - other.y);
  }

  public static Vector from(Direction direction) {
    if (direction == Direction.LEFT) {
      return new Vector(ORIENTATION_X_BORDER_LEFT,
          ORIENTATION_Y_BORDER_LEFT);
    } else if (direction == Direction.TOP) {
      return new Vector(ORIENTATION_X_BORDER_TOP,
          ORIENTATION_Y_BORDER_TOP);
    } else {
      return new Vector(ORIENTATION_X_BORDER_RIGHT,
          ORIENTATION_Y_BORDER_RIGHT);
    }
  }
}




Java Source Code List

edu.fmi.android.brickpong.GameActivity.java
edu.fmi.android.brickpong.GameItem.java
edu.fmi.android.brickpong.HomeActivity.java
edu.fmi.android.brickpong.SplashActivity.java
edu.fmi.android.brickpong.listeners.OnGameEventsListener.java
edu.fmi.android.brickpong.listeners.OnPositionChangedListener.java
edu.fmi.android.brickpong.utils.Direction.java
edu.fmi.android.brickpong.utils.ScreenUtil.java
edu.fmi.android.brickpong.utils.Vector.java
edu.fmi.android.brickpong.view.BallView.java
edu.fmi.android.brickpong.view.BorderView.java
edu.fmi.android.brickpong.view.CellView.java
edu.fmi.android.brickpong.view.FinishedGameView.java
edu.fmi.android.brickpong.view.GameLayout.java
edu.fmi.android.brickpong.view.PadView.java
edu.fmi.android.brickpong.view.ResultsView.java