package engine;

import utils.Point2f;
import utils.Utils;

public final class GameToComponentCoordCalc {

	private static float x, y;
	public static Point2f convert(Point2f p){
		x = (float)(p.x * Math.cos(-Utils._45 * (Game.rotation - 1)) - (p.y * Math.sin(-Utils._45 * (Game.rotation - 1))));
		y = (float)(p.x * Math.sin(-Utils._45 * (Game.rotation - 1)) + (p.y * Math.cos(-Utils._45 * (Game.rotation - 1))));
		
		return new Point2f(x  / Game.scaleFactor - Camera.x, y  / Game.scaleFactor - Camera.y);
	}
	
	
	private static int intX, intY;
	public static int convertX(int x, int y){
		intX = (int)(x * Math.cos(-Utils._45 * (Game.rotation - 1)) - (y * Math.sin(-Utils._45 * (Game.rotation - 1))));
		return (int)(intX  / Game.scaleFactor - Camera.x);
	} public static int convertX(float x, float y){ return convertX((int)x, (int)y); }
	public static int convertY(int x, int y){
		intY = (int)(y * Math.sin(-Utils._45 * (Game.rotation - 1)) + (y * Math.cos(-Utils._45 * (Game.rotation - 1))));
		return (int)(intY  / Game.scaleFactor - Camera.y);
	} public static int convertY(float x, float y){ return convertY((int)x, (int)y); }
}
