protected bool IsTouchingBottom(MmtAnimatedSprite sprite)
 {
     return(Rectangle.Top + Velocity.Y < sprite.Rectangle.Bottom &&
            Rectangle.Bottom > sprite.Rectangle.Bottom &&
            Rectangle.Right > sprite.Rectangle.Left &&
            Rectangle.Left < sprite.Rectangle.Right);
 }
        private bool PerPixelCollision(MmtAnimatedSprite target)
        {
            var sourceColors = new Color[_animations.First().FrameWidth *_animations.First().FrameHeight];

            _animations.First().Texture.GetData(sourceColors);

            var targetColors = new Color[target._animations.First().FrameWidth *target._animations.First().FrameHeight];

            target._animations.First().Texture.GetData(sourceColors);

            var left   = Math.Max(Rectangle.Left, target.Rectangle.Left);
            var top    = Math.Max(Rectangle.Top, target.Rectangle.Top);
            var width  = Math.Min(Rectangle.Right, target.Rectangle.Right) - left;
            var height = Math.Min(Rectangle.Bottom, target.Rectangle.Bottom) - top;

            var intersectingRectangle = new Rectangle(left, top, width, height);

            for (var x = intersectingRectangle.Left; x < intersectingRectangle.Right; x++)
            {
                for (var y = intersectingRectangle.Top; y < intersectingRectangle.Bottom; y++)
                {
                    var sourceColor = sourceColors[(x - Rectangle.Left) + (y - Rectangle.Top) * _animations.First().FrameWidth];
                    var targetColor = targetColors[(x - target.Rectangle.Left) + (y - target.Rectangle.Top) * target._animations.First().FrameWidth];

                    if (sourceColor.A > 0 && targetColor.A > 0)
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
 protected bool IsTouchingRight(MmtAnimatedSprite sprite)
 {
     return(Rectangle.Left + Velocity.X < sprite.Rectangle.Right &&
            Rectangle.Right > sprite.Rectangle.Right &&
            Rectangle.Bottom > sprite.Rectangle.Top &&
            Rectangle.Top < sprite.Rectangle.Bottom);
 }