package engine 
{
	import flash.geom.Point;
	/**
	 * ...
	 * @author Fiodar Paulavets
	 * @version 1.3
	 * @since 11.06.2012
	 */
	public class Utils 
	{
		
		public static function Aspire(s: Number, aim: Number, speed: Number): Number
		{
			var b: Boolean = true;
			if (s + speed < aim) { s += speed; b = false; }
			if (s - speed > aim) { s -= speed; b = false; }
			if (b) s = aim;
			return s;			
		}
		
		public static function AspireDegrees(s: Number, aim: Number, speed: Number): Number
		{
			if (Math.abs(aim - s) > 180)
			{
				if (s > aim)
					aim += 360;
				else
					aim -= 360;
			}
			return Aspire(s, aim, speed);
		}
		
		public static function AbsPoint(point: Point): Point
		{
			point.x = Math.abs(point.x);
			point.y = Math.abs(point.y);
			return point;
		}
		
		public static function Sign(number: Number): int
		{
			if (number > 0)
				return 1;
			if (number < 0)
				return -1;
			return 0;
		}
		
		public static var seed: uint = 1;
		
		public static function randomBySeed(): Number
		{
			seed = (seed * 16807) % 2147483647;
			return seed / 2147483647;
		}
		
	}

}