public void OnCircleCollision(DrawAble sprite1, DrawAble sprite2)
 {
     Vector2 Direction = sprite2.CenterofSprite - sprite1.CenterofSprite;
        Direction.Normalize();
        int DistanceBetween = sprite1.CollisionRadius + sprite2.CollisionRadius;
        Direction *= DistanceBetween;
        sprite1.CenterofSprite += Direction;
 }
        /// <summary>
        /// Input Two Sprites to see if their Collidable Rectangles Intersect.
        /// </summary>
        /// <param name="Sprite1"></param>
        /// <param name="sprite2"></param>
        /// <returns></returns>
        public static bool RectBasedCollision(DrawAble Sprite1, DrawAble sprite2)
        {
            if (Sprite1.GetCollisionRect.Intersects(sprite2.GetCollisionRect))
            {
                RectCollided.OnRectCollided(Sprite1, sprite2);
                return(true);
            }

            return(false);
        }
        /// <summary>
        /// Input Two Sprites to see if their Collidable Rectangles Intersect.
        /// </summary>
        /// <param name="Sprite1"></param>
        /// <param name="sprite2"></param>
        /// <returns></returns>
        public static bool RectBasedCollision(DrawAble Sprite1, DrawAble sprite2)
        {
            if (Sprite1.GetCollisionRect.Intersects(sprite2.GetCollisionRect))
              {
              RectCollided.OnRectCollided(Sprite1, sprite2);
              return true;
              }

              return false;
        }
 /// <summary>
 /// Input two Sprties to see if their Radius Based Collision Happens or not.
 /// </summary>
 /// <param name="sprite1"></param>
 /// <param name="sprite2"></param>
 /// <returns></returns>
 public static bool CircleBasedSpriteCollision(DrawAble sprite1, DrawAble sprite2)
 {
     Vector2 Distance = sprite1.CenterofSprite - sprite1.CenterofSprite;
       if(Distance.Length() < (sprite1.CollisionRadius + sprite2.CollisionRadius))
       {
       CircleCollision.OnCircleCollision(sprite1, sprite2); //Stuff to do after Collision has been detected. To be Decided How to Implement this.
       return true;
       }
       return false;
 }
Ejemplo n.º 5
0
        public void OnCircleCollision(DrawAble sprite1, DrawAble sprite2)
        {
            Vector2 Direction = sprite2.CenterofSprite - sprite1.CenterofSprite;

            Direction.Normalize();
            int DistanceBetween = sprite1.CollisionRadius + sprite2.CollisionRadius;

            Direction *= DistanceBetween;
            sprite1.CenterofSprite += Direction;
        }
        /// <summary>
        /// Input two Sprties to see if their Radius Based Collision Happens or not.
        /// </summary>
        /// <param name="sprite1"></param>
        /// <param name="sprite2"></param>
        /// <returns></returns>
        public static bool CircleBasedSpriteCollision(DrawAble sprite1, DrawAble sprite2)
        {
            Vector2 Distance = sprite1.CenterofSprite - sprite1.CenterofSprite;

            if (Distance.Length() < (sprite1.CollisionRadius + sprite2.CollisionRadius))
            {
                CircleCollision.OnCircleCollision(sprite1, sprite2); //Stuff to do after Collision has been detected. To be Decided How to Implement this.
                return(true);
            }
            return(false);
        }