Пример #1
0
        /// <summary>
        /// Sets the area the bounds could maximally cover with the current SpeedVelocity (any direction).
        /// Rectangle on x and y axes.
        /// </summary>
        internal void UpdateCoverableArea()
        {
            float minX  = float.PositiveInfinity;
            float minY  = float.PositiveInfinity;
            float maxX  = float.NegativeInfinity;
            float maxY  = float.NegativeInfinity;
            float speed = SpeedVelocity;

            foreach (Point pnt in Bounds.GetPoints())
            {
                if (pnt.X < minX)
                {
                    minX = pnt.X;
                }
                if (pnt.X > maxX)
                {
                    maxX = pnt.X;
                }
                if (pnt.Y < minY)
                {
                    minY = pnt.Y;
                }
                if (pnt.Y > maxY)
                {
                    maxY = pnt.Y;
                }
            }

            CoverableArea = new Rectangle(minX - speed, minY - speed, maxX - minX + speed, maxY - minY + speed);
        }
Пример #2
0
        /// <summary>
        /// Draws the outline of a shape. Drawing filled shapes is (currently?) only possible for AABB's. See DrawFilledRect.
        /// </summary>
        public static void DrawShapeOutline(Shape shape, Color color, int depth = 0)
        {
            //add the start point at the end of the array so it will draw the last line
            Point[] shapePoints = shape.GetPoints();
            Point[] points      = new Point[shapePoints.Length + 1];
            shapePoints.CopyTo(points, 0);
            points[points.Length - 1] = points[0];

            DrawJobs.Add(new LineDrawJob(depth, shape.GetEnclosingRectangle(), points, color));
        }
Пример #3
0
        /// <summary>
        /// Draws the outline of a shape. Drawing filled shapes is (currently?) only possible for AABB's. See DrawFilledRect.
        /// </summary>
        public static void DrawShapeOutline(Shape shape, Color color, int depth = 0)
        {
            //add the start point at the end of the array so it will draw the last line
            Point[] shapePoints = shape.GetPoints();
            Point[] points = new Point[shapePoints.Length + 1];
            shapePoints.CopyTo(points, 0);
            points[points.Length - 1] = points[0];

            DrawJobs.Add(new LineDrawJob(depth, shape.GetEnclosingRectangle(), points, color));
        }