예제 #1
0
        /// <summary>
        /// Angle between two FlxPoints
        /// </summary>
        /// <param name="Point1"></param>
        /// <param name="Point2"></param>
        /// <returns></returns>
        internal static float getAngle(FlxPoint Point1, FlxPoint Point2)
        {
            float x = Point2.x - Point1.x;
            float y = Point2.y - Point1.y;

            if ((x == 0) && (y == 0))
            {
                return(0);
            }
            float c1    = 3.14159265f * 0.25f;
            float c2    = 3 * c1;
            float ay    = (y < 0)?-y:y;
            float angle = 0;

            if (x >= 0)
            {
                angle = c1 - c1 * ((x - ay) / (x + ay));
            }
            else
            {
                angle = c2 - c1 * ((x + ay) / (ay - x));
            }
            angle = ((y < 0)?-angle:angle) * 57.2957796f;
            if (angle > 90)
            {
                angle = angle - 270;
            }
            else
            {
                angle += 90;
            }
            return(angle);
        }
예제 #2
0
        /// <summary>
        /// Distance between two FlxPoints
        /// </summary>
        /// <param name="Point1"></param>
        /// <param name="Point2"></param>
        /// <returns></returns>
        internal static float getDistance(FlxPoint Point1, FlxPoint Point2)
        {
            float dx = Point1.x - Point2.x;
            float dy = Point1.y - Point2.y;

            return((float)Math.Sqrt(dx * dx + dy * dy));
        }
예제 #3
0
        /**
         * Pathfinding helper function, strips out even more points by raycasting from one point to the next and dropping unnecessary points.
         *
         * @param	Points		An array of <code>FlxPoint</code> nodes.
         */
        protected void raySimplifyPath(List <FlxPoint> Points)
        {
            FlxPoint source    = Points[0];
            int      lastIndex = -1;
            FlxPoint node;
            int      i = 1;
            int      l = Points.Count;

            while (i < l)
            {
                node = Points[i++];
                if (node == null)
                {
                    continue;
                }
                if (ray(source, node, _point))
                {
                    if (lastIndex >= 0)
                    {
                        Points[lastIndex] = null;
                    }
                }
                else
                {
                    source = Points[lastIndex];
                }
                lastIndex = i - 1;
            }
        }
예제 #4
0
        /// <summary>
        /// A more precise angle between two FlxPoints???
        /// </summary>
        /// <param name="Point1"></param>
        /// <param name="Point2"></param>
        /// <returns></returns>
        internal static float getAnglePrecise(FlxPoint Point1, FlxPoint Point2)
        {
            float x = Point2.x - Point1.x;
            float y = Point2.y - Point1.y;

            return((float)Math.Atan2(y, x) * 180 / (float)Math.PI);
        }
예제 #5
0
        /**
         * Pathfinding helper function, strips out extra points on the same line.
         *
         * @param	Points		An array of <code>FlxPoint</code> nodes.
         */
        protected void simplifyPath(List <FlxPoint> Points)
        {
            float    deltaPrevious;
            float    deltaNext;
            FlxPoint last = Points[0];
            FlxPoint node;
            int      i = 1;
            int      l = Points.Count - 1;

            while (i < l)
            {
                node          = Points[i];
                deltaPrevious = (node.x - last.x) / (node.y - last.y);
                deltaNext     = (node.x - Points[i + 1].x) / (node.y - Points[i + 1].y);
                if ((last.x == Points[i + 1].x) || (last.y == Points[i + 1].y) || (deltaPrevious == deltaNext))
                {
                    Points[i] = null;
                }
                else
                {
                    last = node;
                }
                i++;
            }
        }
예제 #6
0
        /**
         * Find a path through the tilemap.  Any tile with any collision flags set is treated as impassable.
         * If no path is discovered then a null reference is returned.
         *
         * @param	Start		The start point in world coordinates.
         * @param	End			The end point in world coordinates.
         * @param	Simplify	Whether to run a basic simplification algorithm over the path data, removing extra points that are on the same line.  Default value is true.
         * @param	RaySimplify	Whether to run an extra raycasting simplification algorithm over the remaining path data.  This can result in some close corners being cut, and should be used with care if at all (yet).  Default value is false.
         *
         * @return	A <code>FlxPath</code> from the start to the end.  If no path could be found, then a null reference is returned.
         */
        public FlxPath findPath(FlxPoint Start, FlxPoint End, bool Simplify = true, bool RaySimplify = false)
        {
            //figure out what tile we are starting and ending on.
            int startIndex = (int)((Start.y - y) / _tileHeight) * widthInTiles + (int)((Start.x - x) / _tileWidth);
            int endIndex   = (int)((End.y - y) / _tileHeight) * widthInTiles + (int)((End.x - x) / _tileWidth);

            //check that the start and end are clear.
            if (((_tileObjects[_data[startIndex]] as FlxTile).allowCollisions > 0) ||
                ((_tileObjects[_data[endIndex]] as FlxTile).allowCollisions > 0))
            {
                return(null);
            }

            //figure out how far each of the tiles is from the starting tile
            List <int> distances = computePathDistance(startIndex, endIndex);

            if (distances == null)
            {
                return(null);
            }

            //then count backward to find the shortest path.
            List <FlxPoint> points = new List <FlxPoint>();

            walkPath(distances, endIndex, points);

            //reset the start and end points to be exact
            FlxPoint node;

            node   = points[points.Count - 1] as FlxPoint;
            node.x = Start.x;
            node.y = Start.y;
            node   = points[0] as FlxPoint;
            node.x = End.x;
            node.y = End.y;

            //some simple path cleanup options
            if (Simplify)
            {
                simplifyPath(points);
            }
            if (RaySimplify)
            {
                raySimplifyPath(points);
            }

            //finally load the remaining points into a new path object and return it
            FlxPath path = new FlxPath();
            int     i    = points.Count - 1;

            while (i >= 0)
            {
                node = points[i--] as FlxPoint;
                if (node != null)
                {
                    path.addPoint(node, true);
                }
            }
            return(path);
        }
예제 #7
0
 /**
  * Instantiate a new particle.  Like <code>FlxSprite</code>, all meaningful creation
  * happens during <code>loadGraphic()</code> or <code>makeGraphic()</code> or whatever.
  */
 public FlxParticle() : base()
 {
     lifespan     = 0;
     friction     = 500;
     rotateBy     = 0;
     minSpeed     = new FlxPoint();
     maxSpeed     = new FlxPoint();
     particleRect = null;
 }
예제 #8
0
 /**
  * Clean up memory.
  */
 override public void destroy()
 {
     minParticleSpeed = null;
     maxParticleSpeed = null;
     particleDrag     = null;
     particleClass    = null;
     _point           = null;
     base.destroy();
 }
예제 #9
0
 /// <summary>
 /// Retrieve midpoint of this object in world coordinates
 /// </summary>
 /// <param name="Point"></param>
 /// <returns></returns>
 public FlxPoint getMidpoint(FlxPoint Point = null)
 {
     if (Point == null)
     {
         Point = new FlxPoint();
     }
     Point.x = x + (width / 2);
     Point.y = y + (height / 2);
     return(Point);
 }
예제 #10
0
        public FlxPoint remove(FlxPoint Node)
        {
            int index = nodes.IndexOf(Node);

            if (index >= 0)
            {
                nodes.RemoveAt(index);
            }
            return(null);
        }
예제 #11
0
 public FlxBasic()
 {
     ID              = -1;
     exists          = true;
     active          = true;
     visible         = true;
     alive           = true;
     ignoreDrawDebug = false;
     position        = new FlxPoint();
 }
예제 #12
0
 public void addPoint(FlxPoint Node, bool AsReference = false)
 {
     if (AsReference)
     {
         nodes.Add(Node);
     }
     else
     {
         nodes.Add(new FlxPoint(Node.x, Node.y));
     }
 }
예제 #13
0
 public void addPointAt(FlxPoint Node, int Index, bool AsReference = false)
 {
     if (Index > nodes.Count)
     {
         Index = nodes.Count;
     }
     if (AsReference)
     {
         nodes.Insert(Index, Node);
     }
     else
     {
         nodes.Insert(Index, new FlxPoint(Node.x, Node.y));
     }
 }
예제 #14
0
        // overlapsPoint
        override public Boolean overlapsPoint(FlxPoint Point, Boolean InScreenSpace = false, FlxCamera Camera = null)
        {
            if (!InScreenSpace)
            {
                return((_tileObjects[_data[(int)(((Point.y - y) / _tileHeight) * widthInTiles + (Point.x - x) / _tileWidth)]] as FlxTile).allowCollisions > 0);
            }

            if (Camera == null)
            {
                Camera = FlxG.camera;
            }
            Point.x = Point.x - Camera.scroll.x;
            Point.y = Point.y - Camera.scroll.y;
            getScreenXY(_point, Camera);
            return((_tileObjects[_data[(int)(((Point.y - _point.y) / _tileHeight) * widthInTiles + (Point.x - _point.x) / _tileWidth)]] as FlxTile).allowCollisions > 0);
        }
예제 #15
0
        // overlapsPoint
        override public Boolean overlapsPoint(FlxPoint point, Boolean inScreenSpace = false, FlxCamera camera = null)
        {
            if (!inScreenSpace)
            {
                return((_tileObjects[_data[(int)(((point.Y - Y) / _tileHeight) * widthInTiles + (point.X - X) / _tileWidth)]] as FlxTile).AllowCollisions > 0);
            }

            if (camera == null)
            {
                camera = FlxG.camera;
            }
            point.X = point.X - camera.Scroll.X;
            point.Y = point.Y - camera.Scroll.Y;
            getScreenXY(_tagPoint, camera);
            return((_tileObjects[_data[(int)(((point.Y - _tagPoint.Y) / _tileHeight) * widthInTiles + (point.X - _tagPoint.X) / _tileWidth)]] as FlxTile).AllowCollisions > 0);
        }
예제 #16
0
        public FlxPath(List <FlxPoint> Nodes = null)
        {
            if (Nodes == null)
            {
                nodes = new List <FlxPoint>();
            }
            else
            {
                nodes = Nodes;
            }
            _point            = new FlxPoint();
            debugScrollFactor = new FlxPoint(1, 1);
            ignoreDrawDebug   = false;

            //display path stuff
        }
예제 #17
0
 /// <summary>
 /// Call this to figure out the on-screen position of the object
 /// </summary>
 /// <param name="Point">Take a FlxPoint object and assign the post-scrolled X and Y values of this object to it</param>
 /// <param name="Camera">Which Camera - currently only one exists</param>
 /// <returns></returns>
 public FlxPoint getScreenXY(FlxPoint Point = null, FlxCamera Camera = null)
 {
     if (Point == null)
     {
         Point = new FlxPoint();
     }
     if (Camera == null)
     {
         Camera = FlxG.camera;
     }
     Point.x  = x - (Camera.scroll.x * scrollFactor.x);
     Point.y  = y - (Camera.scroll.y * scrollFactor.y);
     Point.x += (Point.x > 0)?0.0000001f:-0.0000001f;
     Point.y += (Point.y > 0)?0.0000001f:-0.0000001f;
     return(Point);
 }
예제 #18
0
        /// <summary>
        /// Check to see if a point in 2D world space overlaps this FlxObject
        /// </summary>
        /// <param name="Point">The point in world space you want to check</param>
        /// <param name="InScreenSpace">Whether to take scroll factors into account.</param>
        /// <param name="Camera">Which Camera - currently only one exists</param>
        /// <returns></returns>
        public virtual bool overlapsPoint(FlxPoint Point, bool InScreenSpace = false, FlxCamera Camera = null)
        {
            if (!InScreenSpace)
            {
                return((Point.x > x) && (Point.x < x + width) && (Point.y > y) && (Point.y < y + height));
            }

            if (Camera == null)
            {
                Camera = FlxG.camera;
            }
            float X = Point.x - Camera.scroll.x;
            float Y = Point.y - Camera.scroll.y;

            getScreenXY(_point, Camera);
            return((X > _point.x) && (X < _point.x + width) && (Y > _point.y) && (Y < _point.y + height));
        }
예제 #19
0
 /// <summary>
 /// Override to null out variables manually
 /// </summary>
 public override void destroy()
 {
     velocity     = null;
     acceleration = null;
     drag         = null;
     maxVelocity  = null;
     scrollFactor = null;
     _point       = null;
     _rect        = null;
     last         = null;
     //cameras = null;
     if (path != null)
     {
         path.destroy();
     }
     path = null;
 }
예제 #20
0
        /// <summary>
        /// Checks to see if this FlxObject were located at the given position
        /// </summary>
        /// <param name="X">X position you want to check</param>
        /// <param name="Y">Y position you want to check</param>
        /// <param name="ObjectOrGroup">The object or group being tested</param>
        /// <param name="InScreenSpace">Whether to take scroll factors into account.</param>
        /// <param name="Camera">Which Camera - currently only one exists</param>
        /// <returns></returns>
        public virtual bool overlapsAt(float X, float Y, FlxBasic ObjectOrGroup, bool InScreenSpace = false, FlxCamera Camera = null)
        {
            if (ObjectOrGroup is FlxGroup)
            {
                bool results = false;
                int  i = 0; List <FlxBasic> members = new List <FlxBasic>();
                members = (ObjectOrGroup as FlxGroup).members;
                uint length = (uint)members.Count;
                while (i < length)
                {
                    if (overlapsAt(X, Y, members[i++], InScreenSpace, Camera))
                    {
                        results = true;
                    }
                }
                return(results);
            }

            if (ObjectOrGroup is FlxTilemap)
            {
                FlxTilemap tilemap = ObjectOrGroup as FlxTilemap;
                return(tilemap.overlapsAt(tilemap.x - (X - x), tilemap.y - (Y - y), this, InScreenSpace, Camera));
            }

            FlxObject Object = ObjectOrGroup as FlxObject;

            if (!InScreenSpace)
            {
                return((Object.x + Object.width > X) && (Object.x < X + width) &&
                       (Object.y + Object.height > Y) && (Object.y < Y + height));
            }

            if (Camera == null)
            {
                Camera = FlxG.camera;
            }
            FlxPoint objectScreenPos = Object.getScreenXY(null, Camera);

            _point.x  = X - Camera.scroll.x * scrollFactor.x;
            _point.y  = Y - Camera.scroll.y * scrollFactor.y;
            _point.x += (_point.x > 0) ? 0.0000001f : -0.0000001f;
            _point.y += (_point.y > 0) ? 0.0000001f : -0.0000001f;

            return((objectScreenPos.x + Object.width > _point.x) && (objectScreenPos.x < _point.x + width) &&
                   (objectScreenPos.y + Object.height > _point.y) && (objectScreenPos.y < _point.y + height));
        }
예제 #21
0
        /// <summary>
        /// Checks to see if some FlxObject overlaps this FlxObject or FlxGroup.
        /// If the group has a LOT of things in it, it might be faster to use <code>FlxG.ovelaps()</code>
        /// </summary>
        /// <param name="ObjectOrGroup">The object or group being tested</param>
        /// <param name="InScreenSpace">Whether to take scroll factors into account.</param>
        /// <param name="Camera">Which Camera - currently only one exists</param>
        /// <returns></returns>
        public virtual bool overlaps(FlxBasic ObjectOrGroup, bool InScreenSpace = false, FlxCamera Camera = null)
        {
            if (ObjectOrGroup is FlxGroup)
            {
                bool            results = false;
                int             i       = 0;
                List <FlxBasic> members = new List <FlxBasic>();
                members = (ObjectOrGroup as FlxGroup).members;
                //uint l = (uint)(ObjectOrGroup as FlxGroup).length;
                uint length = (uint)members.Count;
                while (i < length)
                {
                    if (overlaps(members[i++], InScreenSpace, Camera))
                    {
                        results = true;
                    }
                }
                return(results);
            }

            if (ObjectOrGroup is FlxTilemap)
            {
                //Since tilemap's have to be the caller, not the target, to do proper tile-based collisions,
                // we redirect the call to the tilemap overlap here.
                return((ObjectOrGroup as FlxTilemap).overlaps(this, InScreenSpace, Camera));
            }

            FlxObject Object = ObjectOrGroup as FlxObject;

            if (!InScreenSpace)
            {
                return((Object.x + Object.width > x) && (Object.x < x + width) &&
                       (Object.y + Object.height > y) && (Object.y < y + height));
            }

            if (Camera == null)
            {
                Camera = FlxG.camera;
            }
            FlxPoint objectScreenPos = Object.getScreenXY(null, Camera);

            getScreenXY(_point, Camera);
            return((objectScreenPos.x + Object.width > _point.x) && (objectScreenPos.x < _point.x + width) &&
                   (objectScreenPos.y + Object.height > _point.y) && (objectScreenPos.y < _point.y + height));
        }
예제 #22
0
        /**
         * Called automatically by the game loop, decides when to launch particles and when to "die".
         */
        override public void update()
        {
            if (target != null)
            {
                FlxPoint t = target.getMidpoint();
                x = t.x;
                y = t.y;
            }

            if (on)
            {
                if (_explode)
                {
                    on = false;
                    uint i = 0;
                    uint l = _quantity;
                    if ((l <= 0) || (l > length))
                    {
                        l = (uint)length;
                    }
                    while (i < l)
                    {
                        emitParticle();
                        i++;
                    }
                    _quantity = 0;
                }
                else
                {
                    _timer += FlxG.elapsed;
                    while ((frequency > 0) && (_timer > frequency) && on)
                    {
                        _timer -= frequency;
                        emitParticle();
                        if ((_quantity > 0) && (++_counter >= _quantity))
                        {
                            on        = false;
                            _quantity = 0;
                        }
                    }
                }
            }
            base.update();
        }
예제 #23
0
        /// <summary>
        /// Instantiates a <code>FlxObject</code>
        /// </summary>
        /// <param name="X">X-coordinate of the object in space</param>
        /// <param name="Y">y-coordinate of the object in space</param>
        /// <param name="Width">Desired width of the rectangle</param>
        /// <param name="Height">Desired height of the rectangle</param>
        public FlxObject(float X = 0, float Y = 0, float Width = 0, float Height = 0)
            : base()
        {
            x          = X;
            y          = Y;
            last       = new FlxPoint(x, y);
            width      = Width;
            height     = Height;
            mass       = 1.0f;
            elasticity = 0.0f;

            health = 1;

            immovable = false;
            moves     = true;

            touching        = NONE;
            wasTouching     = NONE;
            allowCollisions = ANY;

            velocity     = new FlxPoint();
            acceleration = new FlxPoint();
            drag         = new FlxPoint();
            maxVelocity  = new FlxPoint(10000, 10000);

            angle               = 0;
            angularVelocity     = 0;
            angularAcceleration = 0;
            angularDrag         = 0;
            maxAngular          = 10000;

            scrollFactor  = new FlxPoint(1, 1);
            _flicker      = false;
            _flickerTimer = 0;

            _point = new FlxPoint();
            _rect  = new FlxRect();

            path      = null;
            pathSpeed = 0;
            pathAngle = 0;
        }
예제 #24
0
        public Player(int X = 0, int Y = 0)
            : base(X, Y)
        {
            maxVelocity = new FlxPoint(100, 100);
            drag        = new FlxPoint(500, 500);
            makeGraphic(40, 40, FlxColor.CADETBLUE);

            _currPos = new FlxPoint(x, y);
            _lastPos = new FlxPoint(x, y);
            _nodes   = new List <FlxPoint>();
            _nodes.Add(_lastPos);
            _nodes.Add(_currPos);
            _path = new FlxPath(_nodes);

            footsteps = new FlxEmitter(x + width / 2, y + height / 2, 0, this);
            footsteps.makeParticles(FlxG.content.Load <Texture2D>("footsteps"), true, 25, 0f, 0f);
            footsteps.setXSpeed();
            footsteps.setYSpeed();

            _indoors = false;
        }
예제 #25
0
        /**
         * This function can be used both internally and externally to emit the next particle.
         */
        public void emitParticle()
        {
            FlxPoint    t        = target.getMidpoint();
            FlxParticle particle = recycle(typeof(FlxBasic)) as FlxParticle;

            particle.minSpeed   = minParticleSpeed;
            particle.maxSpeed   = maxParticleSpeed;
            particle.lifespan   = lifespan;
            particle.elasticity = bounce;
            if (target != null)
            {
                particle.reset(t.x, t.y);
            }
            else
            {
                particle.reset(x - (Convert.ToInt32(particle.width) >> 1) + FlxG.random() * width, y - (Convert.ToInt32(particle.height) >> 1) + FlxG.random() * height);
            }
            particle.visible = true;
            particle.drag.x  = particleDrag.x;
            particle.drag.y  = particleDrag.y;
            particle.onEmit();
        }
예제 #26
0
        public FlxCamera(float X, float Y, float Width, float Height, float Zoom = 1.0f)
            : base()
        {
            x           = X;
            y           = Y;
            width       = Width;
            height      = Height;
            defaultZoom = 1.0f;
            rotating    = 0.0f;
            scroll      = new FlxPoint();
            _point      = new FlxPoint();
            target      = null;
            deadzone    = null;
            bounds      = null;
            zooming     = Zoom;

            _fxShakeIntensity = 0;
            _fxShakeDuration  = 0;
            _fxShakeComplete  = null;
            _fxShakeOffset    = new FlxPoint();
            _fxShakeDirection = 0;
        }
예제 #27
0
        public FlxSprite(float X = 0, float Y = 0, Texture2D Graphic = null)
            : base(X, Y)
        {
            scale  = new FlxPoint(1.0f, 1.0f);
            offset = new FlxPoint();
            origin = new FlxPoint();
            alpha  = 1.0f;
            _color = Color.White * alpha;

            _animations = new List <FlxAnim>();
            _animated   = false;

            finished    = false;
            _facing     = RIGHT;
            _flipped    = 0;
            _curAnim    = null;
            _curFrame   = 0;
            _curIndex   = 0;
            _frameTimer = 0;

            _callback = null;
            _matrix   = new Matrix();

            if (Graphic == null)
            {
                Graphic = ImgDefault;
            }
            loadGraphic(Graphic);

            angle = 0f;

            camX = camY = 0;
            oX   = X;
            oY   = Y;

            moving = false;
        }
예제 #28
0
 /**
  * Creates a new <code>FlxEmitter</code> object at a specific position.
  * Does NOT automatically generate or attach particles!
  *
  * @param	X		The X position of the emitter.
  * @param	Y		The Y position of the emitter.
  * @param	Size	Optional, specifies a maximum capacity for this emitter.
  */
 public FlxEmitter(float X = 0, float Y = 0, uint Size = 0, FlxObject Target = null) : base(Size)
 {
     //super(Size);
     x                = X;
     y                = Y;
     width            = 0;
     height           = 0;
     minParticleSpeed = new FlxPoint(-100, -100);
     maxParticleSpeed = new FlxPoint(100, 100);
     minRotation      = -360;
     maxRotation      = 360;
     gravity          = 0;
     particleClass    = null;
     particleDrag     = new FlxPoint();
     frequency        = 0.1f;
     lifespan         = 3;
     bounce           = 0;
     _quantity        = 0;
     _counter         = 0;
     _explode         = true;
     on               = false;
     _point           = new FlxPoint();
     target           = Target;
 }
예제 #29
0
        public override void destroy()
        {
            if (_animations != null)
            {
                FlxAnim a;
                int     i = 0;
                int     l = _animations.Count;
                while (i < l)
                {
                    a = _animations[i++];
                    if (a != null)
                    {
                        a.destroy();
                    }
                }
                _animations = null;
            }

            offset    = null;
            origin    = null;
            scale     = null;
            _curAnim  = null;
            _callback = null;
        }
예제 #30
0
        /**
         * Rotates a point in 2D space around another point by the given angle.
         *
         * @param	X		The X coordinate of the point you want to rotate.
         * @param	Y		The Y coordinate of the point you want to rotate.
         * @param	PivotX	The X coordinate of the point you want to rotate around.
         * @param	PivotY	The Y coordinate of the point you want to rotate around.
         * @param	Angle	Rotate the point by this many degrees.
         * @param	Point	Optional <code>FlxPoint</code> to store the results in.
         *
         * @return	A <code>FlxPoint</code> containing the coordinates of the rotated point.
         */
        static public FlxPoint rotatePoint(float X, float Y, float PivotX, float PivotY, float Angle, FlxPoint Point = null)
        {
            float sin     = 0;
            float cos     = 0;
            float radians = Angle * -0.017453293f;

            while (radians < -3.14159265)
            {
                radians += 6.28318531f;
            }
            while (radians > 3.14159265)
            {
                radians = radians - 6.28318531f;
            }

            if (radians < 0)
            {
                sin = 1.27323954f * radians + .405284735f * radians * radians;
                if (sin < 0)
                {
                    sin = .225f * (sin * -sin - sin) + sin;
                }
                else
                {
                    sin = .225f * (sin * sin - sin) + sin;
                }
            }
            else
            {
                sin = 1.27323954f * radians - 0.405284735f * radians * radians;
                if (sin < 0)
                {
                    sin = .225f * (sin * -sin - sin) + sin;
                }
                else
                {
                    sin = .225f * (sin * sin - sin) + sin;
                }
            }

            radians += 1.57079632f;
            if (radians > 3.14159265)
            {
                radians = radians - 6.28318531f;
            }
            if (radians < 0)
            {
                cos = 1.27323954f * radians + 0.405284735f * radians * radians;
                if (cos < 0)
                {
                    cos = .225f * (cos * -cos - cos) + cos;
                }
                else
                {
                    cos = .225f * (cos * cos - cos) + cos;
                }
            }
            else
            {
                cos = 1.27323954f * radians - 0.405284735f * radians * radians;
                if (cos < 0)
                {
                    cos = .225f * (cos * -cos - cos) + cos;
                }
                else
                {
                    cos = .225f * (cos * cos - cos) + cos;
                }
            }

            float dx = X - PivotX;
            float dy = PivotY + Y;           //Y axis is inverted in flash, normally this would be a subtract operation

            if (Point == null)
            {
                Point = new FlxPoint();
            }
            Point.x = PivotX + cos * dx - sin * dy;
            Point.y = PivotY - sin * dx - cos * dy;
            return(Point);
        }