Exemple #1
0
        /**
         * Draw the wall as a line
         **/
        public void draw(SpriteBatch spritebatch, Texture2D texture)
        {
            Texture2D wallText = new Texture2D(spritebatch.GraphicsDevice, 1, 1, false, SurfaceFormat.Color);

            wallText.SetData(new[] { Color.White });
            GeometryTools.DrawLine(spritebatch, wallText, radius, Color.Red, start, end);
        }
Exemple #2
0
        /**
         * Check if motion will collide with the wall
         **/
        public bool collide(Vector2 oldPos, Vector2 newPos)
        {
            Vector2 intersection;

            //Radius not taken into account here, it should be, have to figure out a way to do that...
            return(GeometryTools.Intersects2D(start, end, oldPos, newPos, out intersection));
        }
Exemple #3
0
        public void debugDrawDestination(SpriteBatch spritebatch)
        {
            //debug draw for the pathfinding

            Texture2D wallText = new Texture2D(spritebatch.GraphicsDevice, 1, 1, false, SurfaceFormat.Color);

            wallText.SetData(new[] { Color.White });
            GeometryTools.DrawLine(spritebatch, wallText, 1, Color.Blue, position, destination.Position);
        }
Exemple #4
0
        /**
         * Calculate the next position <br>
         * The calculated move will be redirected according to the rotationOffset ( 0 = none 1 = half turn) <br>
         * Rotation Offset should be between 0 and 2
         */
        public Vector2 calculateNextPos(float rotationOffset, double timeSinceLastUpdate)
        {
            if (rotationOffset > 1 || rotationOffset < -1)
            {
                return(new Vector2(0, 0));
            }

            //Calculate and reduce to maxSpeed if needed
            Vector2 tempMove = destination.Position - position;

            tempMove *= (float)timeSinceLastUpdate;
            //Rotate the move vector by rotationOffset * Pi
            tempMove = GeometryTools.RotateVector2(tempMove, rotationOffset * Math.PI);

            if (tempMove.Length() > maxSpeed)
            {
                tempMove.Normalize();
                tempMove *= (float)timeSinceLastUpdate * maxSpeed;
            }

            return(tempMove + position);
        }