Example #1
0
        //------------------------------------------------------------------------------------------------------------------------
        //														DistanceTo()
        //------------------------------------------------------------------------------------------------------------------------
        /// <summary>
        /// Returns the distance to another Transformable
        /// </summary>
        public float DistanceTo(Transformable other)
        {
            float dx = other.x - x;
            float dy = other.y - y;

            return(Mathf.Sqrt(dx * dx + dy * dy));
        }
Example #2
0
 /// <summary>
 /// Creates a render window in the rectangle given by x,y,width,height.
 /// The camera determines the focal point, rotation and scale of this window.
 /// </summary>
 public Window(int x, int y, int width, int height, GameObject camera)
 {
     _windowX    = x;
     _windowY    = y;
     _width      = width;
     _height     = height;
     this.camera = camera;
     window      = new Transformable();
 }
Example #3
0
		/// <summary>
		/// Returns the inverse matrix transformation, if it exists.
		/// (Use this e.g. for cameras used by sub windows)
		/// </summary>
		public Transformable Inverse() {
			Transformable inv=new Transformable();
			if (scaleX == 0 || scaleY == 0)
				throw new Exception ("Cannot invert a transform with scale 0");
			float cs = _matrix [0];
			float sn = _matrix [1];
			inv._matrix [0] = cs / scaleX;
			inv._matrix [1] = -sn / scaleY;
			inv._matrix [4] = sn / scaleX;
			inv._matrix [5] = cs / scaleY;
			inv.x = (-x * cs - y * sn) / scaleX;
			inv.y = (x * sn - y * cs) / scaleY;
			return inv;
		}
Example #4
0
 //------------------------------------------------------------------------------------------------------------------------
 //                                                        DistanceTo()
 //------------------------------------------------------------------------------------------------------------------------
 /// <summary>
 /// Returns the distance to another Transformable
 /// </summary>
 public float DistanceTo(Transformable other)
 {
     float dx = other.x - x;
     float dy = other.y - y;
     return Mathf.Sqrt(dx * dx + dy * dy);
 }