package ei.engine.math;

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

public class Vector2i implements Comparable{
	private int x;
	private int y;
	
	/**
	 * Creates a vector whit the value zero
	 */
	public Vector2i(){
		this(0,0);
	}
	
	/**
	 * Creates a Vector by the given values
	 * 
	 * @param x The x value
	 * @param y The y value
	 */
	public Vector2i(int x, int y){
		this.x = x;
		this.y = y;
	}
	
	/**
	 * Get the X value
	 * 
	 * @return the x value in the vector
	 */
	public int getX(){
		return x;
	}
	
	/**
	 * Get the Y value
	 * 
	 * @return the y value in the vector
	 */
	public int getY(){
		return y;
	}
	
	public void setX(int sx){
		x = sx;
	}
	
	public void setY(int sy){
		y = sy;
	}
	
	/**
	 * Add to the vector
	 * @param i The amount to add
	 */
	public void add(int i){
		x += i;
		y += i;
	}
	
	/**
	 * Returns a copy of this vector
	 * 
	 * @return A copy of this vector
	 */
	public Vector2i getCopy(){
		return new Vector2i(x,y);
	}
	
	public String toString(){
		return "Vector2i["+x+","+y+"]";
	}

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