Пример #1
0
        /// <summary> Create a new line based on two points
        /// 
        /// </summary>
        /// <param name="start">The start point
        /// </param>
        /// <param name="end">The end point
        /// </param>
        public Line(ROVector2f start, ROVector2f end)
            : base()
        {
            //		float width = Math.Abs(end.getX()-start.getX());
            //		float height = Math.Abs(end.getY()-start.getY());
            //		float xoffset = width/2;
            //		float yoffset = height/2;
            //		if (width < 10) {
            //			width = 10;
            //		}
            //		if (height < 10) {
            //			height = 50;
            //		}
            //		if (end.getY() < start.getY()) {
            //			yoffset = -yoffset;
            //		}
            //		if (end.getX() < start.getX()) {
            //			xoffset = -xoffset;
            //		}
            //TODO: do this properly!
            float radius = System.Math.Max(start.Length(), end.Length());
            bounds = new AABox(0, 0, radius * 2, radius * 2);

            Reconfigure(start, end);
        }
Пример #2
0
 /// <summary> Create a shape
 /// 
 /// </summary>
 /// <param name="bounds">The bounds of the shape
 /// </param>
 public AbstractShape(AABox bounds)
 {
     this.bounds = bounds;
 }
Пример #3
0
        /// <summary> Check if this box Touches another
        /// 
        /// </summary>
        /// <param name="x">The x position of this box
        /// </param>
        /// <param name="y">The y position of this box
        /// </param>
        /// <param name="other">The other box to check against  
        /// </param>
        /// <param name="otherx">The other box's x position
        /// </param>
        /// <param name="othery">The other box's y position
        /// </param>
        /// <returns> True if the boxes Touches
        /// </returns>
        public virtual bool Touches(float x, float y, AABox other, float otherx, float othery)
        {
            float totalWidth = (other.width + width) / 2;
            float totalHeight = (other.height + height) / 2;

            float dx = System.Math.Abs((x + offsetx) - (otherx + other.offsetx));
            float dy = System.Math.Abs((y + offsety) - (othery + other.offsety));

            return (totalWidth > dx) && (totalHeight > dy);
        }
Пример #4
0
 /// <summary> Create a box in the simulation 
 /// 
 /// </summary>
 /// <param name="width">The width of a box
 /// </param>
 /// <param name="height">The hieght of the box
 /// </param>
 public Box(float width, float height)
     : base()
 {
     size.Reconfigure(width, height);
     bounds = new AABox(size.Length(), size.Length());
 }