package ei.engine.math;

/**
 * This class holds 2 float values 
 * 
 * @author Ziver
 */

public class Vector2f implements Comparable{
	private float x;
	private float y;
	
	/**
	 * Creates a vector whit the value zero
	 */
	public Vector2f(){
		this(0,0);
	}
	
	/**
	 * Creates a Vector by the given values
	 * 
	 * @param x The x value
	 * @param y The y value
	 */
	public Vector2f(float x, float y){
		this.x = x;
		this.y = y;
	}
	
	/**
	 * Get the X value
	 * 
	 * @return the x value in the vector
	 */
	public float getX(){
		return x;
	}
	
	/**
	 * Get the Y value
	 * 
	 * @return the y value in the vector
	 */
	public float getY(){
		return y;
	}
	
	/**
	 * Add to the vector
	 * @param i The amount to add
	 */
	public void add(float i){
		x += i;
		y += i;
	}
	
	/**
	 * Add to the vector
	 * @param i The amount to add
	 */
	public void add(Vector2f i){
		x += i.getX();
		y += i.getY();
	}
	
	public String toString(){
		return "Vector2f["+x+","+y+"]";
	}
	

	public int compareTo(Object v) {
		if(x+y > ((Vector2f) v).getX()+((Vector2f) v).getY())
			return 1;
		else if(x+y < ((Vector2f) v).getX()+((Vector2f) v).getY())
			return -1;
		else
			return 0;
	}
}
